TheMario Posted February 18, 2010 Share Posted February 18, 2010 Maybe I just misunderstand the principles of math, but when I round any of the following numbers 4.185, 4.145, 4.225, 4.265 to the hundredths place, the numbers are rounded down instead of up. For example: Round (4.185, 2) -> 4.18 Round (4.145, 2) -> 4.14 Round (4.225, 2) -> 4.22 Round (4.265, 2) -> 4.26 What makes this so bad is that it doesn't happen in every case of a trailing 5. In other words, 4.175 and just about any number in between the ones mentioned above (I did not test them all) round up as they should. I guess my question is: why does this happen? Am I missing something, or has anyone else noticed this? Many of my reports were often a penny off, and I thought I was doing something wrong. Now I see that the function appears to be bugged. Any suggestions? I have already written a function to test for the trailing 5 and add .001 to it in order to force the round up instead of down. Since I am working with money this works for me, but what about folks who are potentially rounding to other decimal places, they'd have to write their own round function altogether I suppose. Oh, and hi I'm TheMario, Nice to meet ya. Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now