Merge pull request 'Parse number as floating-point if it doesn't fit in integer; try hard to use integer when possible though' (#1) from feature/ints_overflow into master
Reviewed-on: #1
This commit is contained in:
commit
8221b4c151
10
jzon.inc.php
10
jzon.inc.php
|
@ -293,10 +293,16 @@ class jzonParser
|
|||
}
|
||||
|
||||
$str_num = substr($this->in, $start, $this->c - $start);
|
||||
|
||||
$fval = floatval($str_num);
|
||||
$ival = intval($str_num);
|
||||
|
||||
if($is_float)
|
||||
$out = floatval($str_num);
|
||||
$out = $fval;
|
||||
else if(($ival < PHP_INT_MAX && $ival > PHP_INT_MIN) || strval($ival) === $str_num)
|
||||
$out = $ival;
|
||||
else
|
||||
$out = intval($str_num);
|
||||
$out = $fval;
|
||||
}
|
||||
|
||||
private function parse_true(&$out)
|
||||
|
|
Loading…
Reference in New Issue