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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

indiantrix

Well-known Member
Joined
Oct 17, 2002
Messages
943
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
 

Doug.T

Board Regular
Joined
Sep 19, 2006
Messages
80
2E-15 means the result is not zero but 0.000000000000002
Try reformatting the cell to fewer decimal places.
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,887
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
 

Forum statistics

Threads
1,171,205
Messages
5,874,347
Members
433,047
Latest member
Babynod

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
Top