generally we take the remainder of the operation of the first thought is to use percent%, but when the divisor is a very large value, beyond the int range, so that the surplus is not accurate.
PHP large number (floating point) to take the remainder function
/** * PHP Large number of remainder * * @param int or float $bn divisor * @param int $SN dividend * @return int remainder *///large number (floating point) method function Kmod ($bn, $SN) {return intval (Fmod (Floatval ($bn), $SN));}
Test code:
Large number (floating point) method function Kmod ($bn, $SN) {return intval (Fmod (Floatval ($bn), $SN));} Integer take redundancy method function mod ($bn, $SN) {return $bn% $sn;} The largest int integer $bn = php_int_max, $sn = 11;var_dump ($bn), Var_dump (Kmod ($bn, $SN)), Var_dump (mod ($bn, $SN)), or//to the largest int integer plus 1$bn = Php_int_max + 1;var_dump ($bn), Var_dump (Kmod ($bn, $SN)), Var_dump (mod ($bn, $SN));
Execution Result:
int 2147483647int 1int 1float 2147483648int 2int-2
Extended reading: PHP redundancy function fmod ()
PHP large number (floating point) to take the remainder