PHP implements the remainder of a large number (floating point number ).
This example describes how to implement the remainder of a large number (floating point number) in PHP. We will share this with you for your reference. The details are as follows:
Generally, the first thing we think of when performing the remainder operation is to use the percent sign %. However, when the divisor is a large value beyond the int range, the remainder is inaccurate.
The remainder function of the php large number (floating point number) is as follows:
/*** Php return the remainder of a large number ** @ param int or float $ bn Division * @ param int $ sn Division * @ return int remainder * // large number (floating point number) remainder method function Kmod ($ bn, $ sn) {return intval (fmod (floatval ($ bn), $ sn ));}
Test code:
// Function Kmod ($ bn, $ sn) {return intval (fmod (floatval ($ bn), $ sn ));} // 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 )); // Add 1 $ bn = PHP_INT_MAX + 1 to the largest int integer; var_dump ($ bn); var_dump (Kmod ($ bn, $ sn )); var_dump (mod ($ bn, $ sn ));
Execution result:
Int 2147483647int 1int 1 float 2147483648int 2int-2