- 1

Modulus

what excactly does the %? i passed the test but dont understand it excactly

20th Nov 2017, 1:07 AM
Danno Haze
Danno Haze - avatar
3 Answers
+ 6
Same as divide but it is used for the remainder Like 12%5 will be equal to 2 as the remainder is 2
20th Nov 2017, 1:37 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 2
Meta/aside: Here's a chart including negative value behavior in Javascript: 12 % 7: 5 -12 % 7: -5 12 % -7: 5 -12 % -7: -5 The result takes the sign of the numerator (dividend); other languages use the sign of the denominator (divisor) and the answer will also be correct, but different. This is a policy decision per language. Not to confuse you (at all), I'm just mentioning this so that you know to check which policy your language uses.
20th Nov 2017, 2:23 AM
Kirk Schafer
Kirk Schafer - avatar
0
It gives you the remainder of an integer division. a%b=a-a*(floor(a/b))
20th Nov 2017, 2:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar