Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Errors When Subtracting.
Written by Allen Wyatt (last updated June 5, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
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 is a great place you can start your research:
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 Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Errors When Subtracting.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-06-05 12:25:15
Michael
Happens with time values as well.
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 © 2024 Sharon Parq Associates, Inc.
Comments