Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MOD() and % operator

Status
Not open for further replies.

FoxRookie

Programmer
Sep 27, 2001
17
US
Can anyone explain how the modulus works. I tried to use %, but the return value was not what i expected. I read the help in fox 6, which says:

Returns the remainder (modulus) obtained by dividing one numeric expression into another

? 3089%60 returns 29 and I was expecting 483...

I think I simply do not understand the mathmatical meaning of modulus. If i did understand, possibly the operator or function may be useful to me.

Thanks, darrin
 
Darrin,
3089 % 60 = 29
3089 / 60 = 51.4833
((3089 / 60) - 51)* 60 = 29

If you do the 'long' division of 3089 by 60, then 29 is the remainder. By definiiton % will always return a number from 0 to (number-1) or 0 -> 59 in this case.

Rick
 
Just some nitpicking [afro]

In words:
Just keep substracting 60 from 3089 untill you are left with an amount that is smaller than 60 and that is the result of 3089%60.


Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top