Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I'm working with the Ceil() function to round up some numbers, but I get unwanted results.
I want to round just numbers with 3 decimal positions, and if the number has 2 decimal positions, no round must be made.
So:
2.285 should be : 2.29
2.28 should be 2.28.
I am using the ceil function, which works well when I have 3 decimal positions. With 3 decimal positions I don't understand what it does:
Ceil(2.21,0.01,0) =2.21 -> Right
Ceil(2.22,0.01,0) =2.23 -> Wrong! Why rounded?
Ceil(2.23,0.01,0) =2.23 -> Right!
Ceil(2.24,0.01,0) =2.25 -> Wrong again! Why rounded?
Why is that happening? Is there some way to know how many decimal positions a number has, so I can use that function only for numbers with 3 decimal positions?
Thank you!
Have a look at this excellent blog post by HIC, Rounding Errors
Have a look at this excellent blog post by HIC, Rounding Errors
Thank you very much for pointing out the reason of why this is happening. I will try to find another way then.