Browse Source

Merge branch 'PHP-7.1' into PHP-7.2

* PHP-7.1:
  Fixed bug #46781 (BC math handles minus zero incorrectly)
pull/2749/merge
Christoph M. Becker 9 years ago
parent
commit
77f3cef35c
  1. 1
      NEWS
  2. 3
      ext/bcmath/libbcmath/src/str2num.c
  3. 16
      ext/bcmath/tests/bug46781.phpt

1
NEWS

@ -8,6 +8,7 @@ PHP NEWS
- BCMath:
. Fixed bug #44995 (bcpowmod() fails if scale != 0). (cmb)
. Fixed bug #46781 (BC math handles minus zero incorrectly). (cmb)
. Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1). (okano1220, cmb)
. Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus). (cmb)

3
ext/bcmath/libbcmath/src/str2num.c

@ -105,5 +105,8 @@ bc_str2num (bc_num *num, char *str, int scale)
for (;strscale > 0; strscale--)
*nptr++ = CH_VAL(*ptr++);
}
if (bc_is_zero (*num))
(*num)->n_sign = PLUS;
}

16
ext/bcmath/tests/bug46781.phpt

@ -0,0 +1,16 @@
--TEST--
Bug #46781 (BC math handles minus zero incorrectly)
--SKIPIF--
<?php
if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
?>
--FILE--
<?php
var_dump(bcadd('-0.0', '-0.0', 1));
var_dump(bccomp('-0.0', '0', 1));
?>
===DONE===
--EXPECT--
string(3) "0.0"
int(0)
===DONE===
Loading…
Cancel
Save