So this is a pretty basic question that probably has a very basic answer. I would just like to to know how I can check if a number is divisible by another number. Very short and quick question...
Help is appreciated!
Thanks!
test them, they return 5 and 6, not 0.33. The left hand integer needs to be the number on the left + 0.33 ... thats the only way to get a remainder of 0.33
TheOriginalBIT, on 07 February 2013 - 03:29 PM, said:
Pharap, on 07 February 2013 - 03:26 PM, said:
eg 5%5.33, 6%6.33
test them, they return 5 and 6, not 0.33. The left hand integer needs to be the number on the left + 0.33 ... thats the only way to get a remainder of 0.33
Yeah my apologies. I was doing that on my phone and didn't test them or really think it through at all. The principle still applies though. Here is the definition from the Lua Reference Manual.
Quote
Modulo is defined as
a % b == a - math.floor(a /b )*b
That is, it is the remainder of a division that rounds the quotient towards minus infinity.
TheOriginalBIT, on 07 February 2013 - 03:29 PM, said:
Pharap, on 07 February 2013 - 03:26 PM, said:
eg 5%5.33, 6%6.33
test them, they return 5 and 6, not 0.33. The left hand integer needs to be the number on the left + 0.33 ... thats the only way to get a remainder of 0.33
Point taken, to be fair, it was 2am at the time lol
At least it shows some of the great uses of modulus.