Php uses the % symbol to take the remainder, that is, the modulo operation, and the meaning of the remainder. please note this. today I see this example in Baidu: http://zhidao.baidu.com/question/41130500.html&
Php take the remainder with % symbol, that is, the modulo operation, take the meaning of the remainder, this thing can be used to pay attention to it, today I see Baidu know this example: http://zhidao.baidu.com/question/41130500.html, I want to study how to obtain the remainder of php!
The questioner wondered why the output above was recorded as 44 rather than the expected 45. if you do this:
Echo 945% 100 // 45
The result should be 45, because php performs the remainder operation on the variables by default.
About php floating point number, laruence blog: http://www.laruence.com/2013/03/26/2884.html
Then let's look at the following php code:
For a large integer, php will overflow and may return a negative number (this is because php uses an integer to take the remainder by default, so you need to convert it to the float type (as shown above )) you can do this:
function Kmod($bn, $sn){return intval(fmod(floatval($bn), $sn));}