cataphract Tue, 08 Feb 2011 21:40:51 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=308150
Log: - Changed default serialize_precision from 100 to 17, as discussed in internals. Changed paths: U php/php-src/branches/PHP_5_3/NEWS A php/php-src/branches/PHP_5_3/ext/standard/tests/serialize/precision.phpt U php/php-src/branches/PHP_5_3/main/main.c A php/php-src/trunk/ext/standard/tests/serialize/precision.phpt U php/php-src/trunk/main/main.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-02-08 21:19:23 UTC (rev 308149) +++ php/php-src/branches/PHP_5_3/NEWS 2011-02-08 21:40:51 UTC (rev 308150) @@ -16,6 +16,8 @@ - Core: . Added ability to connect to HTTPS sites through proxy with basic authentication using stream_context/http/header/Proxy-Authorization (Dmitry) + . Changed default value of ini directive serialize_precision from 100 to 17. + (Gustavo) . Fixed bug #53959 (reflection data for fgetcsv out-of-date). (Richard) . Fixed bug #53577 (Regression introduced in 5.3.4 in open_basedir with a trailing forward slash). (lekensteyn at gmail dot com, Pierre) Added: php/php-src/branches/PHP_5_3/ext/standard/tests/serialize/precision.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/serialize/precision.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/serialize/precision.phpt 2011-02-08 21:40:51 UTC (rev 308150) @@ -0,0 +1,49 @@ +--TEST-- +Default precision is sufficient to serialize all the information in floats +--SKIPIF-- +<?php +if (pack('s', 1) != "\x01\x00") + die("skip test for little-endian architectures"); +--FILE-- +<?php + +$numbers = array( + "0000000000000000", //0 + "2d431cebe2362a3f", //.0002 + "2e431cebe2362a3f", //.0002 + 10^-Accuracy[.0002]*1.01 + "0000000000001000", //2^-1022. (minimum normal double) + "0100000000001000", //2^-1022. + 10^-Accuracy[2^-1022.]*1.01 + "ffffffffffffef7f", //2^1024. (maximum normal double) + "feffffffffffef7f", //2^1024. - 10^-Accuracy[2^1024.] + "0100000000000000", //minumum subnormal double + "0200000000000000", //2nd minumum subnormal double + "fffffffffffff000", //maximum subnormal double + "fefffffffffff000", //2nd maximum subnormal double + "0000000000000f7f", //+inf + "0000000000000fff", //-inf +); + +foreach ($numbers as $ns) { + $num = unpack("d", pack("H*", $ns)); $num = reset($num); + echo "number: ", sprintf("%.17e", $num), "... "; + $num2 = unserialize(serialize($num)); + $repr = unpack("H*", pack("d", $num2)); $repr = reset($repr); + if ($repr == $ns) + echo "OK\n"; + else + echo "mismatch\n\twas: $ns\n\tbecame: $repr\n"; +} +--EXPECT-- +number: 0.00000000000000000e+0... OK +number: 2.00000000000000010e-4... OK +number: 2.00000000000000037e-4... OK +number: 2.22507385850720138e-308... OK +number: 2.22507385850720188e-308... OK +number: 1.79769313486231571e+308... OK +number: 1.79769313486231551e+308... OK +number: 4.94065645841246544e-324... OK +number: 9.88131291682493088e-324... OK +number: 3.87340857288933536e-304... OK +number: 3.87340857288933455e-304... OK +number: 1.06293653832877718e+304... OK +number: -1.06293653832877718e+304... OK Modified: php/php-src/branches/PHP_5_3/main/main.c =================================================================== --- php/php-src/branches/PHP_5_3/main/main.c 2011-02-08 21:19:23 UTC (rev 308149) +++ php/php-src/branches/PHP_5_3/main/main.c 2011-02-08 21:40:51 UTC (rev 308150) @@ -477,7 +477,7 @@ STD_PHP_INI_BOOLEAN("y2k_compliance", "1", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals) STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("serialize_precision", "100", PHP_INI_ALL, OnUpdateLongGEZero, serialize_precision, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("serialize_precision", "17", PHP_INI_ALL, OnUpdateLongGEZero, serialize_precision, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator.output, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, arg_separator.input, php_core_globals, core_globals) Added: php/php-src/trunk/ext/standard/tests/serialize/precision.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/serialize/precision.phpt (rev 0) +++ php/php-src/trunk/ext/standard/tests/serialize/precision.phpt 2011-02-08 21:40:51 UTC (rev 308150) @@ -0,0 +1,49 @@ +--TEST-- +Default precision is sufficient to serialize all the information in floats +--SKIPIF-- +<?php +if (pack('s', 1) != "\x01\x00") + die("skip test for little-endian architectures"); +--FILE-- +<?php + +$numbers = array( + "0000000000000000", //0 + "2d431cebe2362a3f", //.0002 + "2e431cebe2362a3f", //.0002 + 10^-Accuracy[.0002]*1.01 + "0000000000001000", //2^-1022. (minimum normal double) + "0100000000001000", //2^-1022. + 10^-Accuracy[2^-1022.]*1.01 + "ffffffffffffef7f", //2^1024. (maximum normal double) + "feffffffffffef7f", //2^1024. - 10^-Accuracy[2^1024.] + "0100000000000000", //minumum subnormal double + "0200000000000000", //2nd minumum subnormal double + "fffffffffffff000", //maximum subnormal double + "fefffffffffff000", //2nd maximum subnormal double + "0000000000000f7f", //+inf + "0000000000000fff", //-inf +); + +foreach ($numbers as $ns) { + $num = unpack("d", pack("H*", $ns)); $num = reset($num); + echo "number: ", sprintf("%.17e", $num), "... "; + $num2 = unserialize(serialize($num)); + $repr = unpack("H*", pack("d", $num2)); $repr = reset($repr); + if ($repr == $ns) + echo "OK\n"; + else + echo "mismatch\n\twas: $ns\n\tbecame: $repr\n"; +} +--EXPECT-- +number: 0.00000000000000000e+0... OK +number: 2.00000000000000010e-4... OK +number: 2.00000000000000037e-4... OK +number: 2.22507385850720138e-308... OK +number: 2.22507385850720188e-308... OK +number: 1.79769313486231571e+308... OK +number: 1.79769313486231551e+308... OK +number: 4.94065645841246544e-324... OK +number: 9.88131291682493088e-324... OK +number: 3.87340857288933536e-304... OK +number: 3.87340857288933455e-304... OK +number: 1.06293653832877718e+304... OK +number: -1.06293653832877718e+304... OK Modified: php/php-src/trunk/main/main.c =================================================================== --- php/php-src/trunk/main/main.c 2011-02-08 21:19:23 UTC (rev 308149) +++ php/php-src/trunk/main/main.c 2011-02-08 21:40:51 UTC (rev 308150) @@ -448,7 +448,7 @@ STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals) STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("serialize_precision", "100", PHP_INI_ALL, OnUpdateLongGEZero, serialize_precision, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("serialize_precision", "17", PHP_INI_ALL, OnUpdateLongGEZero, serialize_precision, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator.output, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, arg_separator.input, php_core_globals, core_globals)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php