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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i round 23 to nearst 5 or 10 foxpro

Status
Not open for further replies.

godfreyw

Programmer
Aug 30, 2002
2
US
I am try to round 23 to the nearest 5 or 10 how do i do that?
 
Just in case you don't see the other post, here's an ugly one:

STORE 23 TO num

iif(num % 10 = 0, num, ;
iif(num % 10 < 6, num - (num % 10) + 5, ;
iif(num % 10 > 5 , num - (num % 10) + 10, 999999999)))
Dave S.
 
Hi Godfrey,

myNumber = 43
? ROUND(myNumber/5,0)*5 gives rounded to 5
? ROUND(myNumber/25,0)*25 gives rounded to 25
? ROUND(myNumber/10,0)*10 gives rounded to 10
? ROUND(myNumber,-1) gives rounded to 10
? ROUND(myNumber,-2) gives rounded to 100

Hope this helps you :)


ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
temp = 51

? iif(temp%5<3,temp-temp%5,temp+(5-temp%5))
will result in 50

temp = 53 will result in 55
temp = 56 will result in 55
temp = 58 will result in 60

the key to this is the 5, it is the point of round off, of course I am guessing at what you asked by rounding off. Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top