Doc #65280 [Opn->Ver]: Documentation for decoct() incorrect and decoct() behaves strange with float.
| From: | yohgaki@php.net | Date: | Mon, 22 Jul 2013 22:12:02 +0000 |
| Subject: | Doc #65280 [Opn->Ver]: 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-10105@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: yohgaki@php.net
Reported by: ben at chico dot com
-Summary: Documentation for decoct incorrect
+Summary: Documentation for decoct() incorrect and decoct()
behaves strange with float.
-Status: Open
+Status: Verified
Type: Documentation Problem
-Package: Documentation problem
+Package: Math related
Operating System: Any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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