2 minus 2 equals -2E-15????

bruderbell

Active Member
Joined
Aug 29, 2006
Messages
374
I've run into a terribly confusing thing. I'm using a few formulas with time, and I've got it all worked out. But somehow, when I enter the times 14:30 minus 12:30 (the formula makes appropriate conversions) and then subtract 2 from the difference, I don't get zero...rather I get -2E-15. When I use other values (I tried offsetting both values by one minute), I get the appropriate answer of 0. Any clues on this? Bug in excel? Reply to me if you are interested in helping, I can email you a portion of my spreadsheet.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If you intend to subtract 2 Hours from the result, then your formula needs to reflect the "2" as an element of a 24-hour day. That is, the formula will yield a Zero (when formatted to, say, hh:mm) as follows: =14:30-12:30-(2/24). HTH. Larry
 
Upvote 0
2E-15 means the result is not zero but 0.000000000000002
Try reformatting the cell to fewer decimal places.
 
Upvote 0
Hi bruderbell

Computers usually do floating point arithmetics with the numbers converted to binary. This means that you are bound to have rounding errors like the one you are experiencing. So, it's not a bug.

Do not try to use formatting to solve the problem. Formatting doesn't change the value, just the way it's displayed.

You can round the number, in this case for instance to 10 decimals =ROUND(A1,10). This will get you the 0 you want.

For more information:

http://support.microsoft.com/kb/214118/

Hope this helps
PGC
 
Upvote 0

Forum statistics

Threads
1,217,500
Messages
6,137,008
Members
450,038
Latest member
JackOfBlades

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top