โremainder (%)
remainder `r = a % b`, `r` has the same sign as `a`.
JS โฉ operator โฉ arithmetic โฉ remainder (%)
a
%
b
returns
a
, ifa
= ยฑ0 /b
= ยฑInfinity.r
=
a
-
b
*
q
where๏ผq
is the integer such that๏ผr
has the same sign asa
, while being as close to 0 as possible.
โญ remainder (%) and modulo are differentโ ๐ remainder vs. modulo vs. mod
% operator
works for floating-point numbers too.
Last updated