Bug #66450 [NEW]: Casting extremely large E notation strings to floats results in incorrect value
| From: | howard at zedcore dot com | Date: | Thu, 09 Jan 2014 17:40:44 +0000 |
| Subject: | Bug #66450 [NEW]: Casting extremely large E notation strings to floats results in incorrect value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183671@lists.php.net to get a copy of this message | ||
From: howard at zedcore dot com
Operating system: Debian Gnu/Linux "Wheezy" 7.2
PHP version: Irrelevant
Package: *Programming Data Structures
Bug Type: Bug
Bug description:Casting extremely large E notation strings to floats results in incorrect value
Description:
------------
Casting a very large float into a string and back-again results in a
different value.
The string representation of both values from var_dump() is the same,
and as expected.
Reproducible on PHP 5.4.4 and PHP 5.3.10 (Not able to upgrade to the
latest PHP release at work but I'll try to reproduce at home soon).
Test script:
---------------
var_dump(exp(100), (string)exp(100), exp(100) == (string)exp(100),
exp(100) - (string)exp(100));
Expected result:
----------------
float(2.6881171418161E+43)
float(2.6881171418161E+43)
bool(true)
float(0)
Actual result:
--------------
float(2.6881171418161E+43)
float(2.6881171418161E+43)
bool(false)
float(3.5652673131419E+29)
--
Edit bug report at https://bugs.php.net/bug.php?id=66450&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66450&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66450&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66450&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66450&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66450&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66450&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66450&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66450&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66450&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66450&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66450&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66450&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66450&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66450&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66450&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66450&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66450&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66450&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66450&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66450&r=mysqlcfg