# iOS Question20 Mod 250

#### rfresh

##### Well-Known Member
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?

#### klaus

##### Expert
Longtime User
What you expect is :
Value = (20 Mod 250) / 250

The Mod funtion returns the reminder.
20 Mod 250 = 20
270 Mod 250 = 20
520 Mod 250 = 20

#### ilan

##### Expert
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 !

#### rfresh

##### Well-Known Member
Longtime User
Hmmm...ok let me digest that info...thank you.

#### Computersmith64

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

- Colin.

#### Erel

##### B4X founder
Staff member
Longtime User
I'm pretty sure Mod returns an integer
Note that Mod in B4A and B4J supports floating point numbers as well. In B4i you can use Bit.FMod for floating points.

Replies
0
Views
277
Replies
0
Views
622
Replies
1
Views
1K
Replies
46
Views
12K
Replies
18
Views
40K