Re: rounding



You have to explain how the first and last cases are supposed to work. Rounding .5625 to two places should result in .57 and rounding 6.125 to two places should result in 6.13, using mathematical rounding. What rounding are you doing?


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"abcd" <abcd@xxxxxxxx> wrote in message news:E80A0159-BF57-4E93-A68F-6D899B202B5C@xxxxxxxxxxxxxxxx
I am trying to write a rounding function. Rounding to 0.05. e.g.

I should get below results

6.125 --> 6.15
1.699 --> 1.7
1.1985 --> 1.20
0.5625 --> 0.60

Can someone have any sample for this....Plain C/C++ function will also do. I want to write more of a generic function so that it could be used from C/C++ programs so I will avoid using the C# advanced functions.

thanks