Doc #65280 [Ver->Csd]: Documentation for decoct() incorrect and decoct() behaves strange with float.

From: Date: Tue, 21 Jun 2016 15:09:11 +0000
Subject: Doc #65280 [Ver->Csd]: Documentation for decoct() incorrect and decoct() behaves strange with float.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13571@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65280&edit=1 ID: 65280 Updated by: cmb@php.net Reported by: ben at chico dot com Summary: Documentation for decoct() incorrect and decoct() behaves strange with float. -Status: Verified +Status: Closed Type: Documentation Problem Package: Math related Operating System: Any PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. > It behaves strange with float values. Is this expected behavior? The current implementation of decoct() accepts a zval and casts it to long[1]. The result of casting too large floats to int is undefined[2]. So yes, this is expected behavior. [1] <https://github.com/php/php-src/blob/php-7.0.7/ext/standard/math.c#L1225-L1228> [2] <http://php.net/manual/en/language.types.integer.php> Previous Comments: ------------------------------------------------------------------------ [2016-06-21 15:03:45] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339437 Log: Fix #65280: Documentation for decoct() incorrect ------------------------------------------------------------------------ [2013-07-22 22:12:02] yohgaki@php.net I suppose decoct() behaves differently on 32/64 bit platforms Under Linux x86_64 php > foreach(range(60,65) as $v) var_dump(pow(2,$v)-1, decoct(pow(2,$v)-1)); int(1152921504606846975) string(20) "77777777777777777777" int(2305843009213693951) string(21) "177777777777777777777" int(4611686018427387903) string(21) "377777777777777777777" float(9223372036854775808) string(22) "1000000000000000000000" float(18446744073709551616) string(1) "0" float(36893488147419103232) string(1) "0" It behaves strange with float values. Is this expected behavior? BTW, current "precision" ini setting is too small for 64 bit platforms and PHP converts integer to float even if it is with in 64 bit integer. To get above result, increase precision. Changed bug type doc to bug to investigate this behavior. ------------------------------------------------------------------------ [2013-07-17 17:34:09] ben at chico dot com Description: ------------ Documentation says: The largest number that can be converted is 4294967295 in decimal resulting to "37777777777". Test script: --------------- wget http://www.php.net/manual/en/function.decoct.php Expected result: ---------------- The largest number that can be converted depends on the platform in use. For 32 bit platform this is 4294967295 in decimal resulting to "37777777777". For 64 bit platforms this is 9223372036854775807 in decimal resulting to '777777777777777777777'. Actual result: -------------- The largest number that can be converted is 4294967295 in decimal resulting to "37777777777". ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65280&edit=1

« previous php.doc.bugs (#13571) next »