The operator %acts on non-integer values in a way that is not entirely obvious. In expression
n % d
what JavaScript does is find the largest integer (I will call it qto reflect the specification), which is less than n / d. Then he calculates the product d * q, and the result is the difference n - (d * q).
(I just ignored the sign problem).
: n d , . 17 % 3. 17 / 3 - 5.something, q 5, 17 - (5 * 3) 2.
- , IEEE 754 6.6 / 1.1 6; - , 6. , q, 5 6. , 6 - (5 * 1.1) 6 - 5.5, ( , ) 1.1.