Fred expressed some confusion and concern about the results he received when subtracting certain numbers. For instance, when he subtracts 3809717.98 from 3799904.94, he should get -9813.04, but instead gets -9813.04000000003.
What Fred is witnessing is an artifact of Excel's limitations. The problem is ultimately related to how Excel works with floating-point numbers. Computers must store numbers internally as binary values, not as the decimal values we see displayed on the screen. Whole numbers can be stored as binary values relatively easily. When you throw a decimal point into the mix, then storing very large or very small numbers becomes more problematic—Excel just isn't able to store them with absolute precision. Instead, Excel provides an "approximate" result, out to 15 digits (the limits of its precision). Thus, you end up with something like -9813.04000000003, which contain the full 15 digits of precision possible in Excel.
A full discussion of how floating-point numbers are maintained in Excel and computers in general can very quickly get extremely technical. For those who want more information on the topic, here are two places you can start your research:
http://support.microsoft.com/?kbid=78113 http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html
The bottom line is that the only way to get the "exact" results you want, to the number of decimal places you want, is to use the ROUND function in your formulas, as shown here:
=ROUND(3799904.94 - 3809717.98, 2)
You can also, if desired, change the precision used within all formulas by following these steps:
Figure 1. The Advanced options in the Excel Options dialog box.
Now, Excel uses the precision shown on the screen in all of its calculations, instead of doing calculations at the full 15-digit precision it normally maintains.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6176) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Errors When Subtracting.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-12-02 09:15:26
Peter Atherton
Ray
I was surprised that you used the IMSUB function as this is for imaginary numbers. The IM gives the clue. I copied your numbers & tried the following
=G7-H7 = 33318.75
=IMSUB(G7,H7) = 33318.75
=IMSUB(G7,H7)/1 = 33318.75
=IMSUB(G7,H7) *1 = 33318.75
With the last two formulas I had to alter the decimal places. This suggests that the original values are from formulas that should have been rounded to 2 decimals. I suggest wrapping both formulas in the round function
{[fig}]
John
That was a really interesting post but I guess the reason that is is not done is given in the last paragraph and people use the KISS principle when possible.
2019-12-01 17:01:17
John Mann
By way of a point of interest, while it's true that computers genreally convert all numbeers to pure binary for their internal purposes, the convert them back to decimal (or Hex or Octal) for display purposes, it's not necessarily true in the world of digiital electronics. Back in the dim and distant past when I was an electronic technician, we aften had digital circuitry which worked with what we called BCD - binary coded decimal. By way of example a 4-bit counter could either be binary or BCD - the binary ccounter generated an overflow (carry out) at the binary number1111 (deicmal 15) while the BCD counter gernrated it's carray out (Overflow) at the binary count of 1001 (decimal 9). This type of circuitry was extremely usefull if the result had to b e displayed visually, such as, for example a frequency counter or voltmeter.
There is no reason, in principal, that I know of, why a computer could not be constructed which would work with BCD and do all it's maths using BCD. It wold not be the most efficient use of resources, however, and would require that things like alphabet enxoding be done completely differently to how they are done, and would end up using more memory with quite a bit of wasted space.
2018-11-29 13:46:03
Ray Porter
I am an absolute amateur with regards to Excel, however I have experienced this problem continually when subtracting one column of numbers from another (i.e. Business Banking, debits from credits running total) I had tried many suggested methods to no avail. YESTERDAY SUCCESS!!!!
I will assume you have already formatted the answer cell to 2 decimal points. Just add /1 (i.e. divide by one) to your formula and HEY PRESTO correct answer to 2 decimal points. Hope this helps
Actual example:
1042607.04 Debits 1075925.79 Credits Produces 33318.7500000013 Using formula =IMSUB(E3534,D3534)
1042607.04 Debits 1075925.79 Credits Produces 33318.75 Using formula =IMSUB(E3534,D3534)/1
2017-07-04 17:13:17
Andrea
This solution is valid also for Excel 2016
2015-09-11 14:11:10
Richard W
I have been using Excel for a couple of decades now and had never run into a problem with this until now. Thank you for providing the solution.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments