Bug #68797 [NEW]: Number 2.2250738585072012e-308 converted incorrectly
| From: | exploringbinary at gmail dot com | Date: | Sun, 11 Jan 2015 00:53:10 +0000 |
| Subject: | Bug #68797 [NEW]: Number 2.2250738585072012e-308 converted incorrectly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-189876@lists.php.net to get a copy of this message | ||
From: exploringbinary at gmail dot com
Operating system: Windows
PHP version: 5.5.20
Package: Math related
Bug Type: Bug
Bug description:Number 2.2250738585072012e-308 converted incorrectly
Description:
------------
The conversion of the number 2.2250738585072012e-308 (equivalent to
DBL_MIN) to double-precision floating-point is done incorrectly; it is
one ULP too low. It prints back as 2.2250738585072009E-308; it should be
2.2250738585072014e-308 (DBL_MIN).
(The nearby decimal numbers 2.2250738585072013e-308,
2.2250738585072014e-308, 2.2250738585072015e-308, and
2.2250738585072016e-308 all convert correctly to DBL_MIN.)
This is likely due to PHP's old copy of David Gay's dtoa.c; see these
change entries at http://www.netlib.org/fp/changes --
they are probably
what is needed:
Wed Feb 12 00:40:01 EST 1997
dtoa.c: strtod: on IEEE systems, scale to avoid intermediate
underflows when the result does not underflow; compiling with
-DNO_IEEE_Scale restores the old logic. Fix a bug, revealed by
input string 2.2250738585072012e-308, in treating input just less
than the smallest normalized number. (The bug introduced an extra
ULP of error in this special case.)
Fri May 15 07:49:07 EDT 1998
dtoa.c: strtod: fix another glitch with scaling to avoid underflow
with IEEE arithmetic, again revealed by the input string
2.2250738585072012e-308, which was rounded to the largest denormal
rather than the smallest normal double precision number.
Test script:
---------------
<?php ini_set("precision", "17"); echo 2.2250738585072012e-308; ?>
Expected result:
----------------
2.2250738585072014e-308
Actual result:
--------------
2.2250738585072009E-308
--
Edit bug report at https://bugs.php.net/bug.php?id=68797&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68797&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68797&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68797&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68797&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68797&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68797&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68797&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68797&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68797&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68797&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68797&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68797&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68797&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68797&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68797&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68797&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68797&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68797&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68797&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68797&r=mysqlcfg