Doc #53852 [Com]: Bug with conversation from float
| From: | dohardgopro at gmail dot com | Date: | Thu, 27 Jan 2011 14:58:03 +0000 |
| Subject: | Doc #53852 [Com]: Bug with conversation from float | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5879@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53852&edit=1
ID: 53852
Comment by: dohardgopro at gmail dot com
Reported by: dohardgopro at gmail dot com
Summary: Bug with conversation from float
Status: Open
Type: Documentation Problem
Package: Variables related
Operating System: Freebsd AMD64
PHP Version: 5.2.17
Block user comment: N
Private report: N
New Comment:
On my 32bit debian system:
php -r "var_dump((int)((float)4043529379404059246));"
int(171708928)
I think it because of difference between int size on 32bit systems and
64bit
systems
PHP_INT_MAX int 32bit systems = 2147483647
PHP_INT_MAX int 64bit systems = 9223372036854775807
Previous Comments:
------------------------------------------------------------------------
[2011-01-27 15:53:24] dohardgopro at gmail dot com
Add architecture
------------------------------------------------------------------------
[2011-01-27 11:53:11] rquadling@php.net
You should count yourself lucky! At least your conversion is in the
ballpark.
On my 32bit windows ...
php -r "var_dump((int)((float)4043529379404059246));" 381D808C0A3C126E
int(171708928) A3C1200
The hex values shows something interesting.
4043529379404059246 = 0x381D808C0A3C126E
171708928 = 0x000000000A3C1200
4043529379404059136 = 0x381D808C0A3C1200
So, the 32bit truncation is sort of expected, but the chopping of the
lower 8
bits isn't.
------------------------------------------------------------------------
[2011-01-27 11:33:22] dohardgopro at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.float
---
Test script:
---------------
var_dump((int)((float)4043529379404059246));
Output:
4043529379404059136
Expected:
4043529379404059246
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53852&edit=1