|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-05-28 18:57 UTC] phplists at stanvassilev dot com
Description: ------------ Tested on Gentoo, CentOS, OSX. This is possibly NOT related to the Windows NaN bug, as Windows is NOT affected by this issue. However, please test if any fix doesn't cause regression on Windows. NaN > NaN, NaN > 0, NaN < 0 return true, while they should return false in all cases (any comparison where either side is NaN, should return false). Reproduce code: --------------- $NaN = sqrt(-1); var_dump($NaN > $NaN); var_dump($NaN > 0); var_dump($NaN < 0); Expected result: ---------------- float(NAN) bool(false) bool(false) bool(false) Actual result: -------------- float(NAN) bool(true) bool(true) bool(true) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 19:00:01 2025 UTC |
Sorry, previous post was incollect. chrisstocktonaz's patch fixes my first comparison. I think following patch is better. --- php-5.3.1-orig/Zend/zend_operators.c 2010-01-10 20:41:36.000000000 +0900 +++ php-5.3.1/Zend/zend_operators.c 2010-01-10 20:44:58.000000000 +0900 @@ -1360,16 +1360,19 @@ case TYPE_PAIR(IS_DOUBLE, IS_LONG): Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_LVAL_P(op2); + if (zend_isnan(Z_DVAL_P(result))) { Z_DVAL_P(result) = 1; } ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_LONG, IS_DOUBLE): Z_DVAL_P(result) = (double)Z_LVAL_P(op1) - Z_DVAL_P(op2); + if (zend_isnan(Z_DVAL_P(result))) { Z_DVAL_P(result) = 1; } ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2); + if (zend_isnan(Z_DVAL_P(result))) { Z_DVAL_P(result) = 1; } ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS;