#42143 [Asn]: The constant NAN is reported as 0 on Windows build

From: Date: Fri, 03 Aug 2007 05:24:54 +0000
Subject: #42143 [Asn]: The constant NAN is reported as 0 on Windows build
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115703@lists.php.net to get a copy of this message
ID: 42143 Updated by: pajoye@php.net Reported By: zoe at uk dot ibm dot com Status: Assigned Bug Type: Math related Operating System: Windows PHP Version: 5CVS-2007-07-30 (snap) Assigned To: edink New Comment: Little notice about VC6, using it with the very last SDK works. I'm not sure which SDK is used on our win32 build box. It may be a platform sdk bug more than a VC bug. Edin, can you try to upgrade the SDK (if we can upgrade it:)? Previous Comments: ------------------------------------------------------------------------ [2007-08-02 22:27:25] stas@php.net Saw a bug under msvc2005 that can be related to this - get_nan() function produced FP exception. Weird thing is that it happens only if engine is started, shut down and then started again inside the same process. Maybe has something to do with some kind of floating point. Using PHP_DOUBLE_QUIET_NAN_HIGH instead seems to fix the problem. ------------------------------------------------------------------------ [2007-08-02 09:47:42] pajoye@php.net I tried using vc 2k3 and 2k5 and NAN is correctly defined. VC6 seems to have a different way to define/get/use NAN. Maybe we can rely on fmod(1,0) instead (always return NaN on windows). ------------------------------------------------------------------------ [2007-07-31 11:42:49] jani@php.net Edin, can you check if there's some problem with the win32 build in this? ------------------------------------------------------------------------ [2007-07-30 08:05:26] zoe at uk dot ibm dot com Description: ------------ The constant NAN is reported as '0' on the Windows binary downloaded from the snaps.php.net site. The function is correct on Linux. A colleague built locally (on Windows) from source and got the correct value for NAN (ie NAN). We stepped through this code (in basic_functions.c): PHPAPI double php_get_nan(void) { #if HAVE_HUGE_VAL_NAN return HUGE_VAL + -HUGE_VAL; #elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha) double val = 0.0; ((php_uint32*)&val)[1] = PHP_DOUBLE_QUIET_NAN_HIGH; ((php_uint32*)&val)[0] = 0; return val; #elif HAVE_ATOF_ACCEPTS_NAN return atof("NAN"); #else return 0.0/0.0; #endif } and found that the local build goes through the first "if" section, that is, HAVE_HUGE_VAL_NAN is true. We can't step through the Windows binary we downloaded but guessing that it's not executing the same section. Reproduce code: --------------- <?php echo "NAN= "; var_dump(NAN); ?> Expected result: ---------------- NAN= float(NAN) Actual result: -------------- NAN= float(0) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42143&edit=1

« previous php.bugs (#115703) next »