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

Help using the round function in clipper 1

Status
Not open for further replies.

fbizzell

Programmer
Jul 3, 2000
217
Is there a way to make the clipper round function always round up. If I round 1.4285 I want it always to come out 2 not 1
 
You could add .5 to the number before rounding it

Code:
? Round(1.4285 + .5)

Regards

Griff
Keep [Smile]ing
 
Thanks, that works certainly with the example I gave you and I assume it would work with numbers that come out differently such as 1.75 which would also round to 2 even after adding the .5. I am wondering if there is any figure that would not give the desired result. I guess I need to do some testing.
 
Everything rounds exactly as I wanted with one exception. I tested every number from 1.100 to 1.9999 and they all rounded to 2 which is exactly what I wanted. The only number that does not round properly is 1.000. That rounds to 2 and of course I want it to stay at 1. But I can deal with that some other way.
 
You might try adding .499999.... out to the last decimal you will be using. I assume 1.000 plus .4999 will round to 1.00. untested

Jim Rumbaugh
 
You can create a function pretty easily, use the INT() function, to create a second value subtract the two and if there is a difference add one to the INT() variable and you have rounded up one whenever there is a value to the
right of the decimal.

Jim C.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top