From:             crescent at corruptinteractive dot com
Operating system: FreedBSD
PHP version:      4.3.3
PHP Bug Type:     Arrays related
Bug description:  serialize() doesn't work properly with floating point

Description:
------------
This bug only appeared after upgrading from php 4.3.1 to php 4.3.3

When serializing an array of floating point values with a specific decimal
value of significance (ie: thousandths), once the array is serialized,
bogus values are stored after the hundredth decimal position.

Here is a short, simple example:





Reproduce code:
---------------
$array[0] = 0;
$array[1] = 1.111;
$array[2] = 2.222;
$array[3] = 3.333;
$array[4] = 4.444;
$array[5] = 5.555;

$array =  serialize($array);
echo "Array = $array";

Expected result:
----------------
Array =
a:6:{i:0;i:0;i:1;d:1.111;i:2;d:2.222;i:3;d:3.333;i:4;d:4.444;i:5;d:5.555;}


Actual result:
--------------
Array =
a:6:{i:0;i:0;i:1;d:1.1109999999999999875655021241982467472553253173828125;i:2;d:2.221999999999999975131004248396493494510650634765625;i:3;d:3.3330000000000001847411112976260483264923095703125;i:4;d:4.44399999999999995026200849679298698902130126953125;i:5;d:5.55499999999999971578290569595992565155029296875;}

Notice the bogus values after the hundredth decimal place for each array
element.

-- 
Edit bug report at http://bugs.php.net/?id=25425&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25425&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25425&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25425&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25425&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25425&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25425&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25425&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25425&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25425&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25425&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25425&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25425&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25425&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25425&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25425&r=gnused

Reply via email to