Home >Backend Development >PHP Tutorial >php怎么转一个大字符串为 unsigned long long

php怎么转一个大字符串为 unsigned long long

WBOY
WBOYOriginal
2016-06-23 14:10:171268browse

php怎么转一个大字符串为 unsigned long long
字符串为 "13353715570921140386" 
怎么转成一个unsigned long long类型的数字呢?
多谢


回复讨论(解决方案)

php 只有 long 没有 long long

如果你需要做数学运算,抗日义使用 BC 或 gmp 高精度数学函数扩展

能具体说下怎么用么 我想计算 13353715570921140386 % 3的值

echo bcmod('13353715570921140386', 3); //out 2

对不对你自己验证,我验证是对的
$s = '13353715570921140386';
$n = array_sum(str_split($s));
echo $n % 3; //out 2

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn