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

Round a number

Status
Not open for further replies.

mariaor

Technical User
Jul 19, 2010
6
MX
Hello,
This forum was been most helpful. Now I have a new problem, I need to round the numbers I have on a table: if the decimals are more or equal to .8 I need to round the number to the next one, if it is less than .8, to the one before. For example:

I have I need
7.7 7
7.9 8
6.3 6
6.8 7

And so on...
Thanks!
 
Mike was close:
Code:
lnRounded = CEILING(m.lnNumber - 0.7)

Cetin Basoz
MS Foxpro MVP, MCP
 
Hi Mike:

I did not realise the difference but you have a point.

In general, when rounding do you go to the next highest number or you go to the next ABSOLUTE highest number ?

Nasib
 
This is what worked for me:
Replace lnNew with iif(lnoriginal-int(original)>=0.8, int (lnoriginal)+1, int(lnoriginal))
Thanks anyway!
 
I wonder, if int(oldNumber+.2) failed on your data set and at what condition ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top