Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PEAR Math_BigInteger(48) => 0? (case : MATH_BIGINTEGER_MODE => default)

Tags:

php

math

pear

I used PEAR/Math/BigInteger.php

  1. PHP 5.2.5 (cli)
  2. ubuntu

but

$a = new Math_BigInteger(48);
echo $a -> toString()// '0'

Why? is it a bug?

it is specific of MATH_BIGINTEGER_MODE => default

3528 function _int2bytes($x)

pack('N', 48) => 0

we need

if('48'===(string)$x){$this->value=array('48');return;}

like image 487
freddiefujiwara Avatar asked Mar 07 '11 01:03

freddiefujiwara


1 Answers

It works for me on a i686 system:

$ php -r 'require_once "Math/BigInteger.php"; $a = new Math_BigInteger(48); echo $a -> toString();'
48
like image 134
cweiske Avatar answered Oct 14 '22 01:10

cweiske