[PATCH] Fix for 64-bit arch errors in zend_operators.c
| From: | Ard Biesheuvel | Date: | Sat, 13 Sep 2003 15:01:39 +0000 |
| Subject: | [PATCH] Fix for 64-bit arch errors in zend_operators.c | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-4462@lists.php.net to get a copy of this message | ||
Hello group,
Currently, the +, - en * operations in zend_operators in C do their
calculcations on long arguments with doubles, and check if the result
would fit in a long.
This failed for me on FreeBSD/alpha (in some of the math tests), because
doubles are not accurate enough to represent LONG_MIN or LONG_MAX. This
causes the comparison
'((double) LONG_MAX) + 1 > (double) LONG_MAX'
to result in 'false' because they have the same double representation.
Since a lot of tests use LONG_MAX in comparisons, this caused a lot of
them to fail on this architecture.
One solution could be to use long doubles, but in my opinion it is
better to check the sign bit directly.
A patch is attached.
--
Ard