Home > Backend Development > PHP Tutorial > 这是 bug 吗?该如何处理

这是 bug 吗?该如何处理

WBOY
Release: 2016-06-13 12:05:24
Original
877 people have browsed it

这是 bug 吗?
echo 3232238115 % 256; //-221

------解决方案--------------------
应该算是吧,php的取模好像是针对整数的
看手册,有个人写的大整数取模

<br />function my_bcmod( $x, $y ) {<br />    $take = 5;<br />    $mod = '';<br />    do{<br />        $a = (int)$mod.substr( $x, 0, $take );<br />        $x = substr( $x, $take );<br />        $mod = $a % $y;<br />		echo $a.'-'.$x.'-'.$mod.'<br>';<br />    }<br />    while ( strlen($x) ); <br />    return (int)$mod; <br />}<br /><br />echo my_bcmod( "7044060001970316212900", 150 );//50<br /><br />/*<br />070440-60001970316212900-90<br />9060001-970316212900-1<br />197031-6212900-81<br />8162129-00-29<br />2900--50<br />*/
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template