|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-19 12:14 UTC] aharvey@php.net
-Status: Open
+Status: Bogus
[2010-04-19 12:14 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 09:00:01 2025 UTC |
Description: ------------ The problem appears when I want to serialize data like this the test script submitted Output of var_dump : string(201) "a:2:{s:5:"exVAT";a:2:{i:0;d:12.1199999999999992184029906638897955417633056640625;i:1;d:12;}s:6:"incVAT";a:2:{i:0;d:4566768.679999999701976776123046875;i:1;d:34343.33999999999650754034519195556640625;}}" As you can see, the float data became very long... I saw that isn't a bug, but coming from floating data type : => http://www.math.byu.edu/~schow/work/IEEEFloatingPoint.htm Test script: --------------- // Test float function NumericPoint($Data) { return round(floatval(str_replace(',','.', $Data)), 2); } $tab = array("12.1222", "12", "4566768.67676767", "34343.34343434343434"); $infos = array("exVAT" => array(0 => NumericPoint($tab[0]), 1 => NumericPoint($tab[1])), "incVAT" => array(0 => NumericPoint($tab[2]), 1 => NumericPoint($tab[3]))); $SeriaData = serialize($infos); var_dump($SeriaData); // End Expected result: ---------------- I expect to see the good format of my float data Actually, to patch this, I don't convert my string to a float and I use str_replace on my serialize data to delete the double quote and change 's' by 'd'