PHP 4.0 Bug #10411 Updated: number_format returns wrong values
| From: | mark at artshouse dot com | Date: | Fri, 20 Apr 2001 19:14:02 +0000 |
| Subject: | PHP 4.0 Bug #10411 Updated: number_format returns wrong values | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-52083@lists.php.net to get a copy of this message | ||
ID: 10411
User Update by: mark@artshouse.com
Status: Closed
Bug Type: Unknown/Other Function
Description: number_format returns wrong values
That was just a typo on my part entering the information
here. The bug still exists, and I think it specifically
has to do with values set as float,2 from MySQL. It doesn't
happen every time, but I have seen this on at least 5
occasions now (in 5 different sets of code).
I can recreate it within my code, but you don't want me to
paste my code (its all intermingled in a 600 lines of
script)
check it out specifically using values pulled from MySQL
with a type of float,2.
Here's the kicker, if I do something like
$total=number_format($totals,2); print $total; the bug
exists...if I do print number_format($totals,2) it works
normally.
Previous Comments:
---------------------------------------------------------------------------
[2001-04-19 17:53:57] joey@php.net
Try changing:
$total = number_format($calcs_a + calcs_b,2);
to
$total = number_format($calcs_a + $calcs_b,2);
(Note the missing $)
Works just fine here with that small adjustment.
---------------------------------------------------------------------------
[2001-04-19 17:35:01] mark@artshouse.com
number_format returns wrong values in certain situations,
here is a code example...
$value = 504;
$calcs_a = number_format($value,2);
$othervalue = 504;
$calcs_b = number_format($othervalue,2);
$total = number_format($calcs_a + calcs_b,2);
this returns:
$calcs_a is 504.00
$calcs_b is 504.00
$total is 1.00 (should be 1008.00)
I have seen this on several occasions now on multiple
machines/setups/Oses
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=10411