1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-27 04:34:45 +01:00

BigInteger: revamp base-10 regex

new Math_BigInteger('-09') gave 0 back as a number in GMP mode
This commit is contained in:
terrafrost 2013-03-05 08:29:06 -06:00
parent 994c2c6c79
commit 4e06ab52dd

View File

@ -413,7 +413,10 @@ class Math_BigInteger {
break;
case 10:
case -10:
$x = preg_replace('#^(-?[0-9]*).*#', '$1', $x);
// (?<!^)(?:-).*: find any -'s that aren't at the beginning and then any characters that follow that
// (?<=^|-)0*: find any 0's that are preceeded by the start of the string or by a - (ie. octals)
// [^-0-9].*: find any non-numeric characters and then any characters that follow that
$x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x);
switch ( MATH_BIGINTEGER_MODE ) {
case MATH_BIGINTEGER_MODE_GMP: