PHP中有BigInteger类吗? [英] Is there a BigInteger class in PHP?
本文介绍了PHP中有BigInteger类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PHP中是否有BigInteger类?如果是这样,我该如何访问或使用它?
Is there a BigInteger class in PHP? If so, how do I access it or use it?
推荐答案
希望对您有所帮助:
- http://php.net/manual/en/ref.bc.php
- http://php.net/manual/en/ref.gmp.php
Math_BigInteger
来自 http://phpseclib.sourceforge.net/documentation/math.html:
实现一个任意精度的整数算术库.如果可用,则使用gmp或bcmath,否则使用内部实现.
Implements an arbitrary precision integer arithmetic library. Uses gmp or bcmath, if available, and an internal implementation, otherwise.
<?php
include('Math/BigInteger.php');
$a = new Math_BigInteger(2);
$b = new Math_BigInteger(3);
$c = $a->add($b);
echo $c->toString(); // outputs 5
?>
这篇关于PHP中有BigInteger类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文