0

How do you understand modulo and floor division

30th Nov 2016, 8:58 PM
Simon David
2 Answers
+ 7
Floor division ignores any fractional result in division. The result is always rounded down to the nearest whole number. Ex: 9 // 4 = 2. 4 goes into 9 twice, and the fractional part left over is truncated. Modulo division gives the remainder of division. Ex: 9 % 4 = 1. 4 goes into 9 twice, and 1 is left over, which is your result.
30th Nov 2016, 9:13 PM
Tamra
Tamra - avatar
+ 3
How often does 5 go into 17? 3 times. 3*5 = 15, and we have 2 left over (the remainder). 17 // 5 == 3 17 % 5 == 2
30th Nov 2016, 9:13 PM
Schindlabua
Schindlabua - avatar