Round off [message #38487] |
Mon, 22 April 2002 10:21 |
kim
Messages: 116 Registered: December 2001
|
Senior Member |
|
|
I have a field with 1 decimal digit (XX.X). I use round to round off to the tenth decimal. The problem is, as the following example shows, I can't sum up my 3 variables to 8.0. How can round it to the nearest tenth and still get 8.0 when adding them up?
8 * 0.182 = 1.456 Oracle rounds to 1.5
8 * 0.183 = 1.464 Oracle rounds to 1.5
8 * 0.635 = 5.08 Oracle rounds to 5.1
(please notice that .182 + .183 + .635 = 1)
Thanks,
Kim
|
|
|
Re: Round off [message #38500 is a reply to message #38487] |
Tue, 23 April 2002 02:44 |
John R
Messages: 156 Registered: March 2000
|
Senior Member |
|
|
In this case, if you do the rounding before summing, I don't think you can.
If you think about it, every time you round to 1 dp, you either gain or lose 0.049.
So, by summing 3 rounded variables your answer is up to 0.147 out from the correct on.
You should sum the 3 numbers and then round them.
|
|
|