【发布时间】:2011-06-11 04:33:54
【问题描述】:
我正在使用 BCmath 对 64 位无符号整数进行数学运算,我想将 bcmath-object 制作为正常的 int(高、低部分)我该如何实现?
感谢您的帮助
【问题讨论】:
-
难道 bcmath 不是用数字的字符串表示而不是 64 位整数(有符号或无符号)来进行数学运算吗?
我正在使用 BCmath 对 64 位无符号整数进行数学运算,我想将 bcmath-object 制作为正常的 int(高、低部分)我该如何实现?
感谢您的帮助
【问题讨论】:
内置的 BCMath 函数不处理 BCMath 对象本身,它们只是处理字符串以实现任意精度计算。因此,您可以使用普通类型转换回原生 php int。
$val = (int) bcmod( bcpow( "9392", "394" ), "100" );
来自http://php.net/manual/en/book.bc.php,方法签名是
string bcmod ( string $left_operand , string $modulus )
string bcpow ( string $left_operand , string $right_operand [, int $scale ] )
【讨论】: