#22802 [Opn->Bgs]: rounding not working
| From: | georg@php.net | Date: | Thu, 20 Mar 2003 12:24:02 +0000 |
| Subject: | #22802 [Opn->Bgs]: rounding not working | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-36033@lists.php.net to get a copy of this message | ||
ID: 22802
Updated by: georg@php.net
Reported By: php at ken dot guest dot cx
-Status: Open
+Status: Bogus
Bug Type: *Math Functions
Operating System: FreeBSD
PHP Version: 4.3.0
New Comment:
Please read the manual instead to reopen bogus bugs!
round() function rounds, it doesn't cut!
Previous Comments:
------------------------------------------------------------------------
[2003-03-20 05:53:40] php at ken dot guest dot cx
I asked it to round 29.999 (as stored in variable $i) to 2 digits of
precision and was expecting to get 29.99...
reopening
------------------------------------------------------------------------
[2003-03-20 05:50:33] php at ken dot guest dot cx
also:
$ php -r 'echo round(29.99, 2), "\n";'
29.99
$ php -r 'echo round(29.9999, 2), "\n";'
30
these should both pring 29.99
------------------------------------------------------------------------
[2003-03-20 04:44:02] hholzgra@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
you asked it to round and so it did
------------------------------------------------------------------------
[2003-03-20 04:25:26] php at ken dot guest dot cx
in short these should all pring 29.99. they don't:
<?php
$discountrate = 10;
$i = 299.99/100 * $discountrate;
echo "$i\n";
echo sprintf("%.2f",$i), "\n";
echo round($i, 2), "\n";
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22802&edit=1