为什么PEAR Math_BigInteger(48) => ?(case: MATH_BIGINTEGER_MODE =>默认值)

时间:2022-04-06 07:17:26

I used PEAR/Math/BigInteger.php

我用梨/数学/ BigInteger.php

  1. PHP 5.2.5 (cli)
  2. PHP 5.2.5(cli)
  3. ubuntu
  4. ubuntu

but

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

Why? is it a bug?

为什么?这是一个错误吗?

it is specific of MATH_BIGINTEGER_MODE => default

它是特定于MATH_BIGINTEGER_MODE =>的默认值

3528 function _int2bytes($x)

3528功能_int2bytes($ x)

pack('N', 48) => 0

包(“N”,48)= > 0

we need

我们需要

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

如果(' 48 ' = = =(字符串)$ x){ $ this - > value =数组(48);回归;}

1 个解决方案

#1


1  

It works for me on a i686 system:

它适用于i686系统:

$ php -r 'require_once "Math/BigInteger.php"; $a = new Math_BigInteger(48); echo $a -> toString();'
48

#1


1  

It works for me on a i686 system:

它适用于i686系统:

$ php -r 'require_once "Math/BigInteger.php"; $a = new Math_BigInteger(48); echo $a -> toString();'
48