【问题标题】:BCmath php 64bitBCmath php 64位
【发布时间】:2011-06-11 04:33:54
【问题描述】:

我正在使用 BCmath 对 64 位无符号整数进行数学运算,我想将 bcmath-object 制作为正常的 int(高、低部分)我该如何实现?

感谢您的帮助

【问题讨论】:

  • 难道 bcmath 不是用数字的字符串表示而不是 64 位整数(有符号或无符号)来进行数学运算吗?

标签: php 64-bit bcmath


【解决方案1】:

内置的 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 ] )

【讨论】:

  • $res['high'] = (int) bcdiv($ad_t, "4294967296"); $res['low'] = (int) bcmod($ad_t, "4294967296");
猜你喜欢
  • 2013-03-14
  • 2016-09-13
  • 2012-05-18
  • 2016-10-02
  • 2013-07-24
  • 2019-01-07
  • 1970-01-01
  • 2013-07-22
  • 2021-06-15
相关资源
最近更新 更多