Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中有BigInteger类吗?_Php_Biginteger - Fatal编程技术网

PHP中有BigInteger类吗?

PHP中有BigInteger类吗?,php,biginteger,Php,Biginteger,PHP中有BigInteger类吗?如果是,我如何访问或使用它?完整链接: 编辑:Math\u BigInteger 示例来自: 实现任意精度的整数算术库。使用gmp或bcmath(如果可用),否则使用内部实现 <?php include('Math/BigInteger.php'); $a = new Math_BigInteger(2); $b = new Math_BigInteger(3); $c = $a->add($b);

PHP中有BigInteger类吗?如果是,我如何访问或使用它?

完整链接:

编辑:Math\u BigInteger

示例来自:

实现任意精度的整数算术库。使用gmp或bcmath(如果可用),否则使用内部实现

<?php
    include('Math/BigInteger.php');

    $a = new Math_BigInteger(2);
    $b = new Math_BigInteger(3);

    $c = $a->add($b);

    echo $c->toString(); // outputs 5
?>

尽管这个问题已经很老了,但它是在谷歌搜索
biginger PHP
时出现的第一个结果,因此对于任何感兴趣的人,我打开了一个名为providing
biginger
BigDecimal
BigRational
类的库


用法
使用Brick\Math\biginger;
使用Brick\Math\RoundingMode;
补充:

echo BigInteger::of('999999999999999999')->plus(1);
// 10000000000000000000000000
减法:

echo BigInteger::of('100000000000000000')->减(1);
// 9999999999999999999999999
乘法:

echo BigInteger::of('3333')->乘以(11);
// 36666666666666666666666663
分部:

echo BigInteger::of('10000000000000000000')->除以(3,取整模式::向上);
// 333333333333333333334
指数化:

echo biginger::of(11)->power(50);
// 11739085287969531650666649599035831993898213898723001
您可以轻松地链接方法调用:

echo BigInteger::of(3)->乘以(7)->减去(1)->除以(10);

装置 只需使用安装即可完成:

composer需要brick/math

该库在可用时自动使用和扩展,以加快计算速度,但由于采用纯PHP实现,在没有它们的情况下也可以工作。

请重新表述问题;如果不是英语,请使用PHP代码。你想解决什么问题?哦,我只是想!非常感谢。