mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Avoid a round() bug that occurs due to over optimization of C code by gcc.
This bug was confirmed across multiple systems with gcc 2.95.3 & 3.X+
This commit is contained in:
parent
4ea2599301
commit
370ea1c82f
@ -32,6 +32,8 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define PHP_ROUND_FUZZ 0.50000000001
|
||||
|
||||
/* {{{ proto int abs(int number)
|
||||
Return the absolute value of the number */
|
||||
|
||||
@ -143,9 +145,9 @@ PHP_FUNCTION(round)
|
||||
|
||||
return_val *= f;
|
||||
if (return_val >= 0.0)
|
||||
return_val = floor(return_val + 0.5);
|
||||
return_val = floor(return_val + PHP_ROUND_FUZZ);
|
||||
else
|
||||
return_val = ceil(return_val - 0.5);
|
||||
return_val = ceil(return_val - PHP_ROUND_FUZZ);
|
||||
return_val /= f;
|
||||
|
||||
RETURN_DOUBLE(return_val);
|
||||
|
Loading…
Reference in New Issue
Block a user