diff options
author | Scott MacVicar <scottmac@php.net> | 2010-08-22 08:01:34 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2010-08-22 08:01:34 +0000 |
commit | 1e48c71b96282adf4c4a549077261c6c2ccbd715 (patch) | |
tree | f2adb6ba11e0d952c1b22381a344a6cb72f4d5dc | |
parent | 77755af9b65ca89442946be80b545ec9574f1728 (diff) | |
download | php-git-1e48c71b96282adf4c4a549077261c6c2ccbd715.tar.gz |
Fix a bug where two doubles are equal but the maths operation makes it appear false.
Best example with INF where equals and identical produce different results.
<?php
var_dump(INF==INF);
var_dump(INF===INF);
-rw-r--r-- | Zend/zend_operators.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 3a89c9c71f..29db08011c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1410,8 +1410,12 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): - Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); + if (Z_DVAL_P(op1) == Z_DVAL_P(op2)) { + ZVAL_LONG(result, 0); + } else { + 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): |