note 17463 added to function.round

From: Date: Mon, 10 Dec 2001 14:25:18 +0000
Subject: note 17463 added to function.round
Groups: php.notes 
Request: Send a blank email to php-notes+get-22431@lists.php.net to get a copy of this message
the following: $int = 0.293847289472983; echo $int ."\n"; echo round($int,2) . "\n"; echo round((int)$int,2) . "\n"; echo round((float)$int,2) . "\n"; echo round((double)$int,2) . "\n"; outputs on php 4.0.6: 0.29384728947298 0.29 0 0.29 0.29 however, using php 4.1.0, it outputs: 0.29384728947298299761570206101168878376483917236328125 0.289999999999999980015985556747182272374629974365234375 0 0.289999999999999980015985556747182272374629974365234375 0.289999999999999980015985556747182272374629974365234375 thus, be aware that round() should no longer be used for output. As previously commented, use [s]printf() for that. -- http://www.php.net/manual/en/function.round.php http://master.php.net/manage/user-notes.php?action=edit+17463 http://master.php.net/manage/user-notes.php?action=delete+17463 http://master.php.net/manage/user-notes.php?action=reject+17463

« previous php.notes (#22431) next »