Incorrect 15th decimal causing rounding errors

%3CLINGO-SUB%20id%3D%22lingo-sub-1211483%22%20slang%3D%22en-US%22%3EIncorrect%2015th%20decimal%20causing%20rounding%20errors%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1211483%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20spreadsheet%20to%20create%20Golf%20Handicap%20Tables.%26nbsp%3B%20The%20first%20column%20ranges%20from%20%2B5.0%20to%2054.0%20in%20steps%20of%26nbsp%3B%200.1%26nbsp%3B%20for%20a%20total%20of%20591%20rows.%26nbsp%3B%20The%20column%20is%20displayed%20to%201%20decimal.%26nbsp%3B%20But%20if%20the%20same%20values%20are%20displayed%20to%2016%20decimals%2C%20an%20extraneous%20digit%20is%20appearing%20in%20some%20rows%20in%20the%2015th%20decimal%20place.%26nbsp%3B%20Calculations%20done%20on%20the%20values%20in%20that%20column%20can%20produce%20results%20like%207.49999999999999%26nbsp%3B%20instead%20of%207.5000000%20-%20that%20causes%20rounding%20down%20to%207.4%20instead%20of%207.5.%26nbsp%3B%20It's%20easy%20enough%20to%20fix%2C%20but%20if%20you%20don't%20know%20it's%20happening%2C%20you%20can%20get%20incorrect%20results%20as%20I%20did.%26nbsp%3B%20Attached%20spreadsheet%20demonstrates%20the%20problem.%26nbsp%3B%20I%20can%20see%20no%20pattern%20in%20the%20way%20the%20unwanted%20digits%20appear.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1211483%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1211503%22%20slang%3D%22en-US%22%3ERe%3A%20Incorrect%2015th%20decimal%20causing%20rounding%20errors%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1211503%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20a%20question%20that%20has%20been%20asked%20many%20times%20before.%20See%20this%20article%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CU%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%20color%3D%22%230b0117%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Ftroubleshoot%2Fexcel%2Ffloating-point-arithmetic-inaccurate-result%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Ftroubleshoot%2Fexcel%2Ffloating-point-arithmetic-inaccurate-result%3C%2FA%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1211504%22%20slang%3D%22en-US%22%3ERe%3A%20Incorrect%2015th%20decimal%20causing%20rounding%20errors%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1211504%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F575289%22%20target%3D%22_blank%22%3E%40adnwilson%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20have%20discovered%20an%20example%20of%20floating%20point%20precision.%20Learn%20more%20here%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fblog%2F2008%2F04%2F10%2Funderstanding-floating-point-precision-aka-why-does-excel-give-me-seemingly-wrong-answers%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fblog%2F2008%2F04%2F10%2Funderstanding-floating-point-precision-aka-why-does-excel-give-me-seemingly-wrong-answers%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1211568%22%20slang%3D%22en-US%22%3ERE%3A%20Incorrect%2015th%20decimal%20causing%20rounding%20errors%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1211568%22%20slang%3D%22en-US%22%3EThanks%2C%20understood.%20Though%20'seemingly%20wrong%20answer'%20ducks%20the%20issue%20a%20bit%20-%20the%20answers%20I%20got%2C%20as%20displayed%2C%20were%20definitely%20wrong%2C%20and%20if%20I%20hadn't%20been%20able%20to%20compare%20them%20with%20results%20from%20a%20different%20source%20I'd%20never%20have%20known%20they%20were%20wrong.%20But%20I%20guess%20there's%20nothing%20to%20be%20done%20about%20it%2C%20which%20seems%20a%20shame.%3C%2FLINGO-BODY%3E
New Contributor

I have a spreadsheet to create Golf Handicap Tables.  The first column ranges from +5.0 to 54.0 in steps of  0.1  for a total of 591 rows.  The column is displayed to 1 decimal.  But if the same values are displayed to 16 decimals, an extraneous digit is appearing in some rows in the 15th decimal place.  Calculations done on the values in that column can produce results like 7.49999999999999  instead of 7.5000000 - that causes rounding down to 7.4 instead of 7.5.  It's easy enough to fix, but if you don't know it's happening, you can get incorrect results as I did.  Attached spreadsheet demonstrates the problem.  I can see no pattern in the way the unwanted digits appear.

3 Replies

This is a question that has been asked many times before. See this article:

https://docs.microsoft.com/en-us/office/troubleshoot/excel/floating-point-arithmetic-inaccurate-resu...

Hello @adnwilson,

 

You have discovered an example of floating point precision. Learn more here:

https://www.microsoft.com/en-us/microsoft-365/blog/2008/04/10/understanding-floating-point-precision...

Thanks, understood. Though 'seemingly wrong answer' ducks the issue a bit - the answers I got, as displayed, were definitely wrong, and if I hadn't been able to compare them with results from a different source I'd never have known they were wrong. But I guess there's nothing to be done about it, which seems a shame.