A question about floating point modulo operation is a routine in the book & lt ;? Php $ a5; $ b3; echo & nbsp; $ a $ B % $ B ;? & Gt; the result of the above case Modulo is 1. The following is my personal understanding, but I am not sure. please give me your answers. $ A $ B Get a floating-point number as the divisor and % B as the divisor. when the divisor is floating-point and smaller than the divisor, the modulo is less than 1, whether to automatically add the first digit after the decimal point to 1 without rounding it out: a question about floating point modulo
A routine in the book
$ A = 5;
$ B = 3;
Echo $ a/$ B % $ B;
?>
The result of the above case Modulo is 1.
The following is my personal understanding, but I am not sure. please give me your answers.
$ A/$ B Get a floating point number as the divisor and % B as the divisor to perform the modulo operation. when the divisor is floating and less than the divisor, the number of modulo operations is less than 1, does it mean to automatically add the first digit after the decimal point to 1 without rounding it down?
Share: More
------ Solution --------------------
Decimal place, integer modulo
Echo $ a/$ B; // 1.6666666666667.
Echo 1.6666666666667% $ B; // 1
------ Solution --------------------
The division operator always returns a floating point number. Only in the following cases: both operands are integers (or integers converted into strings) and can be fully divided. in this case, an integer is returned.
The operands of the modulo operator are converted to integers (excluding decimal digits) before the operation ).