[PHP-CVS] cvs: php-src /ext/standard/tests/math bug45712.phpt ZendEngine2 zend_operators.c
tony2001Thu Aug 7 08:36:15 2008 UTC Modified files: /ZendEngine2zend_operators.c /php-src/ext/standard/tests/mathbug45712.phpt Log: fix bug #45712 ($something == NaN returns true with 5.3, false with 5.2.*) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.292r2=1.293diff_format=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.292 ZendEngine2/zend_operators.c:1.293 --- ZendEngine2/zend_operators.c:1.292 Thu Jul 24 20:38:43 2008 +++ ZendEngine2/zend_operators.cThu Aug 7 08:36:15 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_operators.c,v 1.292 2008/07/24 20:38:43 moriyoshi Exp $ */ +/* $Id: zend_operators.c,v 1.293 2008/08/07 08:36:15 tony2001 Exp $ */ #include ctype.h @@ -1975,15 +1975,18 @@ return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_LONG(result, Z_DVAL_P(op1)((double)Z_LVAL_P(op2))?1:(Z_DVAL_P(op1)((double)Z_LVAL_P(op2))?-1:0)); + Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_LVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_LONG(result, ((double)Z_LVAL_P(op1))Z_DVAL_P(op2)?1:(((double)Z_LVAL_P(op1))Z_DVAL_P(op2)?-1:0)); + Z_DVAL_P(result) = (double)Z_LVAL_P(op1) - Z_DVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): - ZVAL_LONG(result, Z_DVAL_P(op1)Z_DVAL_P(op2)?1:(Z_DVAL_P(op1)Z_DVAL_P(op2)?-1:0)); + Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_ARRAY, IS_ARRAY): http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/math/bug45712.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/math/bug45712.phpt diff -u php-src/ext/standard/tests/math/bug45712.phpt:1.1 php-src/ext/standard/tests/math/bug45712.phpt:1.2 --- php-src/ext/standard/tests/math/bug45712.phpt:1.1 Tue Aug 5 12:36:21 2008 +++ php-src/ext/standard/tests/math/bug45712.phpt Thu Aug 7 08:36:15 2008 @@ -50,13 +50,13 @@ bool(false) bool(false) bool(false) -bool(true) bool(false) bool(false) bool(false) bool(false) bool(false) -bool(true) +bool(false) +bool(false) float(INF) bool(true) bool(false) @@ -64,7 +64,7 @@ bool(false) bool(false) bool(false) -bool(true) +bool(false) bool(false) bool(false) bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard/tests/math bug45712.phpt ZendEngine2 zend_operators.c
Antony Dovgal kirjoitti: tony2001Thu Aug 7 08:36:15 2008 UTC Modified files: /ZendEngine2 zend_operators.c /php-src/ext/standard/tests/math bug45712.phpt Log: fix bug #45712 ($something == NaN returns true with 5.3, false with 5.2.*) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.292r2=1.293diff_format=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.292 ZendEngine2/zend_operators.c:1.293 --- ZendEngine2/zend_operators.c:1.292 Thu Jul 24 20:38:43 2008 +++ ZendEngine2/zend_operators.cThu Aug 7 08:36:15 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_operators.c,v 1.292 2008/07/24 20:38:43 moriyoshi Exp $ */ +/* $Id: zend_operators.c,v 1.293 2008/08/07 08:36:15 tony2001 Exp $ */ #include ctype.h @@ -1975,15 +1975,18 @@ return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_LONG(result, Z_DVAL_P(op1)((double)Z_LVAL_P(op2))?1:(Z_DVAL_P(op1)((double)Z_LVAL_P(op2))?-1:0)); + Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_LVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_LONG(result, ((double)Z_LVAL_P(op1))Z_DVAL_P(op2)?1:(((double)Z_LVAL_P(op1))Z_DVAL_P(op2)?-1:0)); + Z_DVAL_P(result) = (double)Z_LVAL_P(op1) - Z_DVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): - ZVAL_LONG(result, Z_DVAL_P(op1)Z_DVAL_P(op2)?1:(Z_DVAL_P(op1)Z_DVAL_P(op2)?-1:0)); + Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_ARRAY, IS_ARRAY): http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/math/bug45712.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/math/bug45712.phpt diff -u php-src/ext/standard/tests/math/bug45712.phpt:1.1 php-src/ext/standard/tests/math/bug45712.phpt:1.2 --- php-src/ext/standard/tests/math/bug45712.phpt:1.1 Tue Aug 5 12:36:21 2008 +++ php-src/ext/standard/tests/math/bug45712.phpt Thu Aug 7 08:36:15 2008 @@ -50,13 +50,13 @@ bool(false) bool(false) bool(false) -bool(true) bool(false) bool(false) bool(false) bool(false) bool(false) -bool(true) +bool(false) +bool(false) float(INF) bool(true) bool(false) @@ -64,7 +64,7 @@ bool(false) bool(false) bool(false) -bool(true) +bool(false) bool(false) bool(false) bool(false) You fixed by changing the test to be wrong? :) Is not $nan == $nan or $nan === $nan true ? --Jani -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard/tests/math bug45712.phpt ZendEngine2 zend_operators.c
On 07.08.2008 14:02, Jani Taskinen wrote: You fixed by changing the test to be wrong? :) No, I fixed the test to show the same behavior with 4.4, 5.2, 5.3 and HEAD. I also fixed comparison of NaN with empty strings and numbers. Is not $nan == $nan or $nan === $nan true ? No, they are not equal: A NaN does not compare equal to any floating-point number or NaN, even if the latter has an identical representation. One can therefore test whether a variable has a NaN value by comparing it to itself (i.e. if then x is NaN). http://en.wikipedia.org/wiki/NaN -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard/tests/math bug45712.phpt ZendEngine2 zend_operators.c
Antony Dovgal kirjoitti: On 07.08.2008 14:02, Jani Taskinen wrote: You fixed by changing the test to be wrong? :) No, I fixed the test to show the same behavior with 4.4, 5.2, 5.3 and HEAD. I also fixed comparison of NaN with empty strings and numbers. Ok. Is not $nan == $nan or $nan === $nan true ? No, they are not equal: A NaN does not compare equal to any floating-point number or NaN, even if the latter has an identical representation. One can therefore test whether a variable has a NaN value by comparing it to itself (i.e. if then x is NaN). http://en.wikipedia.org/wiki/NaN I stand corrected. Thanks. --Jani -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard/tests/math bug45712.phpt ZendEngine2 zend_operators.c
On Thu, 7 Aug 2008, Antony Dovgal wrote: On 07.08.2008 14:02, Jani Taskinen wrote: You fixed by changing the test to be wrong? :) No, I fixed the test to show the same behavior with 4.4, 5.2, 5.3 and HEAD. I also fixed comparison of NaN with empty strings and numbers. Is not $nan == $nan or $nan === $nan true ? No, they are not equal: A NaN does not compare equal to any floating-point number or NaN, even if the latter has an identical representation. One can therefore test whether a variable has a NaN value by comparing it to itself (i.e. if then x is NaN). http://en.wikipedia.org/wiki/NaN It's like NULL in SQL... regards, Derick -- HEAD before 5_3!: http://tinyurl.com/6d2esb http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php