I have started to learn Javascript. From book http://eloquentjavascript.net:
There is one more arithmetic operator which is probably less familiar to you. The
%
symbol is used to represent the remainder operation.X % Y
is the remainder of dividingX
byY
. For example314 % 100
is14
,10 % 3
is1
, and144 % 12
is0
. Remainder has the same precedence as multiplication and division.
I don't understand, why it multiply the remainder fraction by divisor (after division). It is more complicated or less accurate.
10 / 3 = 3.3333 (a recurring decimal number). 10 % 3 = 1 (0.333 * 3 = 0.999 (not 1 )
What is purpose of this strange remainders ?
Thanks
0.999...
is 1. See en.wikipedia.org/wiki/0.999...