iOS Question 20 Mod 250

rfresh

Well-Known Member
Licensed User
Longtime User
20 divided by 250 == 0.08

I'm trying to get the remainder:

value = 20 Mod 250

value returns 20 but the remainder is .08 so I must be doing something wrong?
 

ilan

Expert
Licensed User
Longtime User
value returns 20 but the remainder is .08 so I must be doing something wrong?

i am nut sure i understand what you mean.
MOD is not equal to DIVIDE

mod (as you mentioned) is the remainder of a number substract the "mod" number like

13 mod 3 will do

13 - 3 = 10
10 - 3 = 7
7 - 3 = 4
4 - 3 = 1
1 - 3 < 0 so the remainder is 1

as long the number can substract the "mod" number but still stay positive the mod function will do it. when you get a negative number the mod function will stop and return the remained number.

20 mod 250 will try to substract 250 from 20 so it will do 20 - 250 what will return -230 so its a negative number so the mod will stop and return the last positive number.

another example

27 mod 12 will do
27 - 12 = 15
15 - 12 = 3
3 - 12 = -9 !!!! MOD: oh no its a negative number return back to the last positive number and thats 3

so 27 mod 12 = 3 ! ;)
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Or put more simply, I'm pretty sure Mod returns an integer (ie: a whole number).

- Colin.
 
Upvote 0
Top