ID: 25425 Updated by: [EMAIL PROTECTED] Reported By: crescent at corruptinteractive dot com -Status: Open +Status: Bogus Bug Type: Arrays related -Operating System: FreedBSD +Operating System: * PHP Version: 4.3.3 New Comment:
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 We had to fix several other weired things with serializing and floats. As a result we now store more digits. But still the value is the same. That's the way floating point values work - we simply can't hide that from you anymore. Previous Comments: ------------------------------------------------------------------------ [2003-09-08 02:45:35] crescent at corruptinteractive dot com Temporary fix - cast the array elements of float type to a string before serialize(). Use settype($array, "string") ------------------------------------------------------------------------ [2003-09-08 02:24:15] crescent at corruptinteractive dot com 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 this bug report at http://bugs.php.net/?id=25425&edit=1