Rounding up & Down to 2 decimal places

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
I have a double with about 8 number after the decimal place. How do you display just 2 after the decimal place?

Thanks,
G.
 
Rounding upto 2 decimals

i am using round of method for 2 decimal places it works fine for

round(1.646,2) ---> 1.65

But, if i use

round(1.645,2) --> 1.64

which is not correct could you please help on this
 
uthrauthra said:
i am using round of method for 2 decimal places it works fine for

round(1.646,2) ---> 1.65

But, if i use

round(1.645,2) --> 1.64

which is not correct could you please help on this

vb uses statistical rounding that that is correct

ie: 1.5 will round to 2, and 2.5 will also round to 2
3.5 will round to 4, and 4.5 will also round to 4
 
some other way to round upto two decimals

how can this be solved. is there any other way to solve this it is very critical.please provide a solution.

Thank u

regards,
utr
 
As with anything in programming, if the provided functions do not give the desired output, you will have to code it yourself.

You will need to find if the 3rd decimal place is 0 - 4 or 5-9 and round the second decimal place accordingly. Then decide if you want to consider 1.1449 to be 1.14 or 1.15.
 
Back
Top