+ 1

could smbd explane me what "%" operator do?

a%b what is the result of this formula?

25th Feb 2018, 2:51 PM
ledenec
ledenec - avatar
5 Answers
+ 6
a%b=Remainder % gives you the remainder after all division is done. Examples ------------------------------------- 11%2 .. this results in 1 because.. 2 goes into 10 evenly, and leaves 1 remaining. 2,4,6,8,10 ... 1 remaining 18%5 .. this results in 3 because.. 5 goes into 15 evenly and leaves 3 remaining. 5,10, 15 ... 3 remaining ------------------------------------- practical use.. If n % 2 == 0 .. n is an even number .. because after 2 goes into n as much as possible there isn't a leftover. 2 goes into it evenly Hope this helped
25th Feb 2018, 3:03 PM
LordHill
LordHill - avatar
+ 5
It’s the remainder after you divide the 2 numbers. Example 5/2 has a remainder of 1, so 5%2 =1.
27th Feb 2018, 4:27 AM
Scott
+ 1
You could also think of it as: x%y Substract y of x as often as posdible without the result getting negative... Or what you've propably been doing in the elementary school: "How often does y fit in x and what will remain (thats what you get: the remainder of the division)"
25th Feb 2018, 6:04 PM
D B
D B - avatar
0
briefly its modulus
26th Feb 2018, 6:25 AM
Mert TĂŒrkan
Mert TĂŒrkan - avatar
- 2
__________________
26th Feb 2018, 2:47 PM
mlglord
mlglord - avatar