+ 5

Why we are used modulus only for integer ?and not for float?

for solving reminder

4th Oct 2018, 4:42 PM
Keshav Halade
Keshav Halade - avatar
2 odpowiedzi
0
because a modulus simply does this 10 % 3 (10>3) 10-3=3 (7>3) 7-3=4 (4>3) 4-3=1 (1<3) 10%3=1 so unless you really need to use modulus on a decimal precision, you dont need it for int's
4th Oct 2018, 8:21 PM
~Just Another Brick In The Wall~
~Just Another Brick In The Wall~ - avatar
0
Because you don't have a remainder when when dividing with floats - at least when you want your result to be float, too.
6th Oct 2018, 3:33 AM
Chris
Chris - avatar