 |
iliekater Level: Master
 Registered: 04-02-2005 Posts: 123
|
How to Round a number ?
Here's a tricky one : If someone wants to to get the rounded value of a number , he can use the Round function , for example :
| MyRoundedValue = Round(MyNumber , 2) |
my problem , however , is that I don't want to round my value to a specific decimal place , instead I want to round itto a specific decimal value , that is 0.75 .
for Example I want 3.79 to be rounded to 4 , while 2.68 to the value 2 .
Is it possibleto use the Round function (or any other) for this purpose ?
Up to now , the only way I have thought about , is comparing the double value with integer part (using the Int function) , but this requires too much of code ...
|
|
22-03-2007 at 10:30 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: How to Round a number ?
There are of course more complex ways like:
rounded_number = Int(x) + IIf(x - Int(x) - 0.75 >= 0, 1, 0)
but just subtracting the .25 from the number and using the round function is easier (and probably a few milliseconds quicker).
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
23-03-2007 at 06:57 PM |
|
|
iliekater Level: Master
 Registered: 04-02-2005 Posts: 123
|
Re: How to Round a number ?
Oh man , you are a genius !
|
|
23-03-2007 at 10:38 PM |
|
|
|
|
 |
 |