Modulo and floor division? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Modulo and floor division?

Could somebody explain it to me I’m 14 and I don’t think we learn modulo in Australia. I’ve never hear of either of these things.

7th Jul 2018, 12:09 PM
Madeline Grace
Madeline Grace - avatar
3 Respuestas
+ 2
You definitely know about division and how it was done in elementary school. For example to calculate 7/2 you have to look how many 2's fit in there. Obviously 3, because 3*2=6 but 4*2 = 8, which is too much. However, there is still some rest. 7 = 3*2 +1 And this rest is the result for 7%2. Therefore modulo is just a compact way to note it down. Floor division is much simpler. Everything after the decimal point is just cropped. 3.213 -> 3 3.817 -> 3 (mostly done for integer division) Ceil would be the other way round 3.213 -> 4 3.817 -> 4 And normal round 3.213 -> 3 3.817 -> 4
7th Jul 2018, 12:37 PM
Matthias
Matthias - avatar
+ 3
modulo is the remainder from division. say 5/2 = 2.5, 5%2 = 1
7th Jul 2018, 12:39 PM
ReShaun Pintard
ReShaun Pintard - avatar
+ 2
floor division is if you say 5/2, instead of saying 2.5 is the answer you say 2. because you round it down to the nearest integer. or number without decimals
7th Jul 2018, 12:40 PM
ReShaun Pintard
ReShaun Pintard - avatar