Bug #68797 [Opn->Ver]: Number 2.2250738585072012e-308 converted incorrectly

From: Date: Mon, 12 Jan 2015 16:39:29 +0000
Subject: Bug #68797 [Opn->Ver]: Number 2.2250738585072012e-308 converted incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189908@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68797&edit=1 ID: 68797 Updated by: ab@php.net Reported by: exploringbinary at gmail dot com Summary: Number 2.2250738585072012e-308 converted incorrectly -Status: Open +Status: Verified Type: Bug Package: Math related Operating System: Windows PHP Version: 5.5.20 Block user comment: N Private report: N New Comment: I can reproduce this. But from what I see on the internets like here http://patrakov.blogspot.de/2009/03/dont-use-old-dtoac.html the version you point to can possibly have issues with gcc. Lets see if there's a commit history somewhere for that file. Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-01-11 00:53:10] exploringbinary at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=68797&edit=1

« previous php.bugs (#189908) next »