Doc #53852 [Opn]: Bug with conversation from float
| From: | rquadling@php.net | Date: | Thu, 27 Jan 2011 10:53:12 +0000 |
| Subject: | Doc #53852 [Opn]: Bug with conversation from float | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5877@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
Updated by: rquadling@php.net
Reported by: dohardgopro at gmail dot com
Summary: Bug with conversation from float
Status: Open
Type: Documentation Problem
Package: Variables related
Operating System: Freebsd
PHP Version: 5.2.17
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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