Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding error in excel when substracting 1

Status
Not open for further replies.

valerian95

IS-IT--Management
Aug 6, 2003
3
CA
Hi,

I've got a problem when rounding results in Excel XP.

When I round to 1 decimal the number: 0.95 I get: 1.0.
But when I round : (24.95 - 24.00) to 1 decimal, I get: 0.9!

Since 24.95 - 24.00 = 0.95, why don't excel give me the same result when rounding it than when I type directly 0.95?

I even tried:
=round(0.95; 1) (that gives 1.0)
and:
=round(24.95 - 24.00; 1) (and that still gives 0.9)

Strangely, the problem does not occur when I add numbers: =round(0.50 + 0.45; 1) gives correctly 1.0.

Why excel round differently when there is a substraction implied? Do you have any suggestion on how to fix it?

Any hints?

Thanks!
 
If you format your numbers to a large number of decimal places, you should see that 24.95 - 24 equals .949999999999 not .95, so it rounds to .9 when rounding to 1 decimal place.

If it is really important, than you can round twice like this:
[blue]
Code:
   =ROUND(ROUND(A1-B1,9),1)
[/color]

(assuming A1=24.95 and B1=24) and you should see the result you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top