Serious bug with certain decimal numbers: Countifs and Roundup failed

%3CLINGO-SUB%20id%3D%22lingo-sub-2314149%22%20slang%3D%22en-US%22%3ESerious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314149%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20file%20that%20had%20time%20upto%20the%20seconds%20level.%20Some%20of%20these%20numbers%20had%2099999..%20after%20the%20fifth%20decimal%20digit.%20And%20all%20these%20numbers%20seem%20to%20throw%20a%20major%20bug.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20wanted%20to%20find%20out%20how%20many%20entries%20were%20made%20on%20or%20before%20the%20current%20time.%20Shocking%20excel%20returned%20the%20answer%20as%20zero%20for%20those%20times%20or%20numbers%20with%2099%20in%20the%20sixth%20decimal%20point%20onwards%20(which%20is%20impossible%20because%20the%20time%20is%20already%20in%20the%20array).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20even%20tried%20rounding%20those%20numbers%20to%20five%20decimal%20points%20but%20it%20didn't%20round.%3CBR%20%2F%3E%3CBR%20%2F%3EOpenOffice%20Calc%2C%20Google%20Sheets%20and%20Zoho%20sheets%20does%20not%20seem%20to%20create%20any%20such%20trouble.%20I%20have%20attached%20the%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20thoughts%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2314149%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314281%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314281%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20using%20MROUND(...%2C%201%2F86400)%3C%2FP%3E%0A%3CP%3E(1%20second%20%3D%201%2F86400%20of%20a%20day)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22S0357.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F277312iE22DC701B8B57B49%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22S0357.png%22%20alt%3D%22S0357.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314687%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314687%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%20wrote%3A%20%60%60Try%20using%20MROUND(...%2C%201%2F86400)%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20that%20is%20ill-advised.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConsider%20Sheet1!B4.%26nbsp%3B%20It%20display%208%3A49%2C%20but%20the%20actual%20value%20is%202%2F1%2F2020%208%3A49%3A48.%26nbsp%3B%20(I%20write%20dates%20in%20the%20form%20MDY.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DISNUMBER(MATCH(%3CFONT%20color%3D%22%23FF0000%22%3EMROUND(B4%2C%201%2F86400)%3C%2FFONT%3E%2C%20B4%2C%200))%20returns%20FALSE(!).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(FYI%2C%20we%20could%20write%20%220%3A0%3A1%22%20with%20double-quotes%20instead%201%2F86400.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20reason%20is%3A%26nbsp%3B%20the%20binary%20result%20from%20MROUND%20does%20not%20match%20the%20binary%20representation%20of%202%2F1%2F2020%208%3A49%3A48.%26nbsp%3B%20In%20fact%2C%20MROUND%20fails%20for%20more%20than%2025%25%20of%20the%20values%20in%20column%20B.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20exact%20binary%20match%20is%20important%20for%20lookups%2C%20for%20example.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20contrast....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DISNUMBER(MATCH(%3CFONT%20color%3D%22%23FF0000%22%3EINT(B4)%2BTEXT(B4%2C%22h%3Am%3As%22)%3C%2FFONT%3E%2C%20B4%2C%200))%20returns%20TRUE%20for%20all%20values%20in%20column%20B.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECaveat%3A%20INT(B4)%2BTEXT(B4%2C%22h%3Am%3As%22)%20works%20for%20constants%20that%20are%20accurate%20to%20the%20second.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20it%20works%20for%20calculated%20date%20and%20time%20that%20results%20in%20less%20than%2023%3A59%3A59.500.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20if%20date%20and%20time%20values%20might%20be%20accurate%20to%20the%201%2F10%20second%20(or%20less)%2C%20the%20following%20rounds%20to%20the%20second%20more%20reliably%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EINT(B4)%2BTEXT(%3CFONT%20color%3D%22%23FF0000%22%3EMOD(B4%2C1)%3C%2FFONT%3E%2C%22%3CFONT%20color%3D%22%23FF0000%22%3E%5Bh%5D%3C%2FFONT%3E%3Am%3As.000%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20reason%20is%3A%26nbsp%3B%20Excel%20rounds%20to%20the%20second%20when%20formatting%20to%20the%20hour%2C%20minute%20or%20second.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConsequently%2C%20for%20example%2C%202%2F1%2F2020%2023%3A59%3A59.6%20displays%20as%202%2F%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3E2%3C%2FFONT%3E%3C%2FSTRONG%3E%2F2020%200%3A00%3A00.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20INT(B4)%2BTEXT(B4%2C%22h%3Am%3As%22)%20would%20incorrectly%20result%20in%202%2F%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3E1%3C%2FFONT%3E%3C%2FSTRONG%3E%2F2020%200%3A00%3A00.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314730%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314730%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20there%20are%20two%20separate%20issues%2C%20and%20it%20is%20unclear%20if%20the%20issue%20that%20you%20focused%20on%20is%20truly%20important%20for%20your%20purposes%20--%20although%20it%20is%20interesting%20curiosity.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20Excel%20has%20a%20%3CEM%3E%3CU%3Eformatting%3C%2FU%3E%3C%2FEM%3E%20defect%20that%20causes%2043863.89142%20to%20be%20displayed%20as%2043863.8914199999%2C%20for%20example.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(MSFT%20used%20to%20document%20the%20defect%20in%20KB161234.%26nbsp%3B%20But%20I%20cannot%20find%20that%20document%20or%20the%20equivalent%20online%20anymore.%26nbsp%3B%20No%20matter.%26nbsp%3B%20The%20KB%20description%20was%20inaccurate%2C%20anyway.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20defect%20is%20specific%20to%20Excel.%26nbsp%3B%20It%20has%20nothing%20to%20do%20with%20the%2064-bit%20binary%20floating-point%20standard.%26nbsp%3B%20That%20is%20why%20you%20do%20not%20see%20it%20in%20other%20applications.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20the%20formatting%20defect%20is%20not%20limited%20to%20ROUNDUP.%26nbsp%3B%20The%20formatting%20defect%20arises%20with%20relatively%20few%20binary%20values%20that%20meet%20very%20specific%20conditions.%26nbsp%3B%20(I%20can%20explain%2C%20if%20you%20wish.%26nbsp%3B%20It%20is%20TMI%20for%20most%20people.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMoreover%2C%20the%20effect%20of%20the%20formatting%20defect%20can%20be%20confusing%20because%20when%20we%20enter%2043863.89142%2C%20%3CEM%3E%3CU%3Einitially%3C%2FU%3E%3C%2FEM%3E%20it%20has%20the%20binary%20value%20of%2043863.89142%2C%20even%20though%20it%20appears%20to%20be%2043863.8914199999.%26nbsp%3B%20But%20if%20we%20edit%20the%20cell%2C%20it%20%3CU%3E%3CEM%3Echanges%3C%2FEM%3E%3C%2FU%3E%20to%20the%20binary%20value%20of%2043863.8914199999%2C%20which%20is%20different.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20initially%20%3DISNUMBER(MATCH(VALUE(%2243863.89142%22)%2C%20%7B%2043863.89142%20%7D%2C%200))%20returns%20TRUE%2C%20even%20though%20it%20appears%20to%20be%20%3DISNUMBER(MATCH(VALUE(%2243863.89142%22)%2C%20%7B%2043863.8914199999%20%7D%2C%200)).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20if%20we%20select%20the%20cell%20and%20press%20f2%2C%20then%20Enter%2C%20the%20formula%20returns%20FALSE.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOTOH%2C%20if%20we%20have%20%3DVALUE(%2243863.89142%22)%20in%20A1%2C%20%3DCOUNTIF(A1%2C%20%22%3D%22%26amp%3B43863.89142)%20always%20returns%20zero%20because%20COUNTIF%20sees%20the%20string%20%22%3D43863.8914199999%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20only%20work-around%20that%20I%20know%20is%20to%20replace%20such%20constants%20with%20expressions%20like%20VALUE(%2243863.89142%22)%2C%20ROUND(%2243863.89142%22%2C5)%2C%20A1%2B%2243863.89142%22%2C%20etc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20key%20is%20to%20enter%20such%20numbers%20in%20double-quotes%20in%20an%20arithmetic%20expression%2C%20when%20you%20encounter%20the%20formatting%20defect.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20the%20real%20question%20is%3A%26nbsp%3B%20why%20are%20you%20using%20ROUNDUP(B4%2C5)%2C%20in%20the%20first%20place%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20Sheet1%2C%20the%20date%20and%20time%20%3CEM%3E%3CU%3Econstants%3C%2FU%3E%3C%2FEM%3E%20in%20column%20B%20are%20already%20accurate%20to%20the%20second.%26nbsp%3B%20There%20is%20no%20need%20to%20round%20them.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20if%20there%20is%20a%20need%20(for%20example%2C%20for%20%3CU%3E%3CEM%3Ecalculated%3C%2FEM%3E%3C%2FU%3E%20date%20and%20time%20values)%2C%20rounding%20to%205%20decimal%20places%20is%20the%20wrong%20way%20to%20do%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInstead%2C%20you%20might%20use%20one%20of%20the%20following%2C%20depending%20on%20your%20requirements.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETEXT(B4%2C%20%22m%2Fd%2Fyyyy%20h%3Am%3As%22)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3E--TEXT(B4%2C%20%22m%2Fd%2Fyyyy%20h%3Am%3As%22)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3EINT(B4)%2BTEXT(B4%2C%22h%3Am%3As%22)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3EINT(B4)%2BTEXT(MOD(B4%2C1)%2C%22%5Bh%5D%3Am%3As%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20provide%20the%20%3CEM%3E%3CU%3Eoriginal%3C%2FU%3E%3C%2FEM%3E%20use%20of%20COUNTIFS%20that%20led%20to%20the%20problem%2C%20we%20can%20be%20more%20specific.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20what%20you%20posted%20in%20your%20attachment%20is%20your%20attempts%20to%20understand%20and%20work%20around%20the%20original%20problem.%26nbsp%3B%20I%20cannot%20%22see%20the%20forest%20for%20the%20trees%22.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314990%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314990%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146717%22%20target%3D%22_blank%22%3E%40Joe%20User%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CP%3EThe%20only%20work-around%20that%20I%20know%20is%20to%20replace%20such%20constants%20with%20expressions%20like%20VALUE(%2243863.89142%22)%2C%20ROUND(%2243863.89142%22%2C5)%2C%20A1%2B%2243863.89142%22%2C%20etc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20key%20is%20to%20enter%20such%20numbers%20in%20double-quotes%20in%20an%20arithmetic%20expression%2C%20when%20you%20encounter%20the%20formatting%20defect.%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3EInteresting.%20I've%20never%20sever%20such%20a%20workaround%20before.%20Will%20keep%20it%20in%20mind.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2315131%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2315131%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146717%22%20target%3D%22_blank%22%3E%40Joe%20User%3C%2FA%3E%26nbsp%3B%2C%20FYI%3C%2FP%3E%0A%3CP%3EClassic%26nbsp%3B%3CSPAN%3EDiego%20Oppenheimer%20post%20which%20explains%20floating%20point%20precision%20is%20here%26nbsp%3B%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%3EUnderstanding%20Floating%20Point%20Precision%2C%20aka%20%E2%80%9CWhy%20does%20Excel%20Give%20Me%20Seemingly%20Wrong%20Answers%3F%E2%80%9D%20-%20Microsoft%20365%20Blog%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMicrosoft%20restructured%20documentation%20with%20introducing%20of%20docs.microsoft.com%2C%20articles%20as%26nbsp%3BKB161234%20are%20here.%20With%20some%20updates%20where%20applicable.%20In%20particular%26nbsp%3Bthis%20one%20is%26nbsp%3B%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%3EFloating-point%20arithmetic%20may%20give%20inaccurate%20result%20in%20Excel%20-%20Office%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2315170%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2315170%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20Excel%20works%20by%20default%20with%2015%20digits%20and%20many%20functions%20ignore%20extra%20digits%2C%20but%20some%20work%20in%20background%20with%2017%20digits.%20More%20about%20that%20is%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.mrexcel.com%2Fexcel-tips%2F17-or-15-digits-of-precision%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E17%20or%2015%20digits%20of%20precision%20-%20Excel%20Tips%20-%20MrExcel%20Publishing%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20this%20particular%20case%20if%20use%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(%20(%24C%241%3A%24C%2411%26lt%3B%3DC4)*(%24B%241%3A%24B%2411%3DB4))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Einstead%20of%20COUNTIFS()%20it%20returns%20correct%20result.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2315360%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2315360%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20a%20detailed%20response%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146717%22%20target%3D%22_blank%22%3E%40Joe%20User%3C%2FA%3E%26nbsp%3Band%20thank%20you%20for%20the%20alternative%20solution%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20had%20a%20list%20of%20end%20users%20with%20various%20entry%20times%20and%20I%20had%20to%20count%20how%20many%20times%20an%20user%20has%20done%20entry%20up%20to%20a%20given%20point.%20So%2C%20I%20wanted%20to%20apply%20this%3A%20%3DCountifs(%5BTime%5D%2C%22%26lt%3B%3D%22%26amp%3B%5B%40Time%5D%2C%5BUser%5D%2C%5B%40User%5D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20is%20when%20I%20noticed%20that%20for%20some%20of%20the%20entries%20I%20was%20getting%20wrong%20answers.%20Roundup%20was%20more%20of%20a%20workaround%20I%20attempted%20to%20fix%20the%20problem.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20didn't%20realise%20this%20issue%20existed%20in%20MS%20Excel.%20Thank%20you%20for%20helping%20me%20understand%20the%20bug.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2315381%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2315381%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%20wrote%3A%3C%2FP%3E%3CP%3E%60%60Classic%20Diego%20Oppenheimer%20post%20which%20explains%20floating%20point%20precision%60%60%3C%2FP%3E%3CP%3Eand%3C%2FP%3E%3CP%3E%60%60articles%20as%20KB161234%20are%20here.%20%5B....%5D%20In%20particular%20this%20one%20is%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%2C%20as%20I%20stated%20clearly%20previously%2C%20this%20%3CU%3E%3CEM%3Eformatting%20defect%3C%2FEM%3E%3C%2FU%3E%20has%20%3CFONT%20color%3D%22%23FF0000%22%3Enothing%20to%20do%20with%2064-bit%20binary%20floating-point%20precision%3C%2FFONT%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20demonstrate%20that%20fact%2C%20note%20that%20when%20we%20enter%2043863.89142%2C%20Excel%20incorrectly%20displays%2043863.8914199999%2C%20but%20%3CFONT%20color%3D%22%23FF0000%22%3EVBA%20correctly%20displays%2043863.89142%3C%2FFONT%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20in%20fact%2C%20the%20binary%20approximations%20are%20different.%26nbsp%3B%20The%20following%20shows%20the%20%3CEM%3E%3CU%3Eexact%3C%2FU%3E%3C%2FEM%3E%20decimal%20representation%20of%20the%20two%20binary%20approximations%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E43863.89142%3A%3C%2FP%3E%3CP%3E43863.891419999%3CFONT%20color%3D%22%23FF0000%22%3E9%2C999%3C%2FFONT%3E2549419403076171875%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E43863.8914199999%3A%3C%2FP%3E%3CP%3E43863.891419999%3CFONT%20color%3D%22%23FF0000%22%3E8%2C980%3C%2FFONT%3E62087595462799072265625%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(I%20use%20period%20for%20the%20decimal%20point%20and%20comma%20to%20demarcate%20the%20first%2015%20significant%20digits.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESecond%2C%20the%20MSFT%20article%20that%20you%20cite%20is%20a%20retitling%20of%20KB%2078113%2C%20not%20KB%20161234.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20aha!%20I%20just%20stumbled%20across%20an%20archived%20version%20of%20KB%20161234%20at%20%3CA%20href%3D%22https%3A%2F%2Fwww.betaarchive.com%2Fwiki%2Findex.php%2FMicrosoft_KB_Archive%2F161234%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EMicrosoft%20KB%20Archive%2F161234%20-%20BetaArchive%20Wiki%3C%2FA%3E%20.%26nbsp%3B%20For%20posterity%2C%20it%20reads%2C%20in%20part%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%60%60when%20you%20type%20or%20calculate%20a%20number%20between%2032%2C768%20and%2065%2C535%20that%20contains%20a%20decimal%20portion%20of%20.848%2C%20the%20number%20is%20evaluated%20and%20displayed%20in%20the%20formula%20bar%20with%20a%20decimal%20portion%20of%20.8479999999.%20%5B....%5D%20Microsoft%20has%20confirmed%20this%20to%20be%20a%20problem%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20KB%20description%20is%20complete.%26nbsp%3B%20The%20formatting%20defect%20is%20%3CEM%3E%3CU%3Enot%20limited%3C%2FU%3E%3C%2FEM%3E%20to%20the%20list%20Excel%20versions%20(5.0%2C%2095%20and%2097).%26nbsp%3B%20Obviously%2C%20it%20applies%20to%20the%20latest%20Excel%20version%20as%20well.%26nbsp%3B%20And%20the%20emphasis%20should%20be%20on%20%3CU%3E%3CEM%3Econstants%3C%2FEM%3E%3C%2FU%3E%20and%20calculations%20that%20we%20%3CEM%3E%3CU%3Eexplicitly%20round%3C%2FU%3E%3C%2FEM%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(Obviously%2C%20unrounded%20calculations%20with%20decimal%20fractions%20are%20susceptible%20to%20the%20anomalies%20of%20binary%20floating-point%20arithmetic%2C%20which%20can%20result%20in%20unexpected%20decimal%20fraction%20digits.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20I%20take%20issue%20with%20the%20statement%3A%26nbsp%3B%20%60%60.848%20%5B...%5D%20is%20evaluated%20%5B...%5D%20with%20a%20decimal%20portion%20of%20.8479999999%60%60.%26nbsp%3B%20As%20I%20noted%20previously%2C%20when%20we%20enter%2043863.89142%2C%20%3CEM%3E%3CU%3Einitially%3C%2FU%3E%3C%2FEM%3E%20the%20value%20that%20appears%20to%2043863.8914199999%20has%20the%20binary%20approximation%20of%2043863.89142.%26nbsp%3B%20It%20is%20changed%20to%20(%22evaluated%20as%22)%20the%20binary%20approximation%20of%2043863.8914199999%20only%20%3CEM%3E%3CU%3Eafter%20we%20edit%3C%2FU%3E%3C%2FEM%3E%20the%20line%20in%20the%20Formula%20Bar.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMore%20importantly%2C%20the%20formatting%20defect%20is%20%3CU%3E%3CEM%3Enot%20limited%3C%2FEM%3E%3C%2FU%3E%20to%20that%20integer%20range%20and%20that%20decimal%20fraction.%26nbsp%3B%20For%20example%2C%20in%20that%20integer%20range%2C%20other%203-digit%20fractions%20are%200.098%2C%200.223%2C%200.348%2C%200.473%2C%200.598%2C%200.723%20and%200.973%20as%20well%20as%200.848.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E's%20examples%20include%205-digit%20fractions%20in%20that%20integer%20range%3B%20for%20example%2C%2043863.89142.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(Caveat%3A%20The%20following%20is%20TMI%20for%20most%20people.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20difficult%20to%20predict%20the%20decimal%20values%20that%20evoke%20the%20formatting%20defect.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20it%20is%20difficult%20for%20me%20to%20explain%20the%20conditions%20that%20evoke%20the%20formatting%20defect%20without%20resorting%20to%20the%20details%20of%20the%20binary%20representation.%26nbsp%3B%20Those%20conditions%20are%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20The%20integer%20part%20of%20the%20number%20is%2065535%20or%20less.%26nbsp%3B%20If%20the%20integer%20part%20is%20zero%2C%20the%20decimal%20fraction%20must%20exceed%200.5.%26nbsp%3B%20And%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2.%20The%20binary%20approximation%20of%20the%20decimal%20fraction%20can%20be%20represented%20in%2032%20bits%3B%20that%20is%2C%20all%20the%20bits%20to%20the%20right%20are%20zero.%26nbsp%3B%20And%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E3.%20The%2016th%20significant%20digit%20of%20the%20exact%20decimal%20representation%20of%20the%20binary%20approximation%20is%205%20or%20more.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20sure%20the%203rd%20condition%20is%20not%20explicit%20in%20the%20Excel%20implementation.%26nbsp%3B%20But%20we%20notice%20a%20formatting%20defect%20only%20when%20the%2015th%20significant%20digit%20%3CU%3E%3CEM%3Eshould%20be%3C%2FEM%3E%3C%2FU%3E%20rounded%20up%2C%20and%20it%20is%20not.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2315596%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2315596%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%2C%20Hans.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20almost%20sorted%20the%20problem.%20But%20there%20were%20still%20a%20few%20numbers%20that%20it%20couldn't%20fix.%20As%20Joe%20mentioned%2C%20there%20seems%20to%20be%20some%20inherent%20problem%20in%20certain%20odd%20cases.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20solution%20that%20Sergei%20gave%20to%20use%20sumproduct%20in%20place%20of%20Countif%20fixed%20the%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2316325%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2316325%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20a%20lot%20of%20rummaging%20around%20on%20Google%2C%20I%20came%20to%20this%20result.%3C%2FP%3E%3CP%3EThe%20short%20answer%20is%2C%20you%20can't%20edit%20your%20numbers%20the%20way%20you%20want%20after%20you've%20entered%20the%20numeric%20value%20and%20hit%20enter.%20The%20moment%20you%20do%20this%2C%20the%20number%20is%20truncated%20to%2015%20digits%20and%20shown%20as%20exponential.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20not%20a%20bug%2C%20it%20is%20a%20function.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEverything%20you%20do%20after%20that%20uses%20the%20truncated%20value%2C%20so%20no%20formatting%20trick%20is%20helpful.%20However%2C%20you%20can%20use%20the%20%E2%80%9CText%20to%20columns%E2%80%9C%20option%20to%20convert%20the%20exponential%20notation%20to%20text%20(click%20on%20the%20column%20heading%2C%20click%20%E2%80%9CText%20to%20data%E2%80%9C%20then%20click%20Delimited%2C%20Next%20uncheck%20all%20delimiting%20boxes%2C%20select%20%E2%80%9CText%20in%20Column%20data%20format%20%22And%20then%20from%22%20Finish%20%22)%20to%20convert%20the%20values%20into%20text%20and%20immediately%20display%20them%20as%20a%2015-digit%20number.%20But%20it%20will%20only%20be%2015%20digits%20so%20if%20you%20had%20a%20longer%20number%20the%20pause%20is%20lost.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20have%20the%20number%20in%20the%20worksheet%20exactly%20as%20you%20entered%20it%2C%20you%20need%20to%20save%20it%20as%20text.%20So%20you%20have%20to%20prepend%20an%20apostrophe%20or%20format%20cells%20as%20text%20before%20you%20can%20enter%20%2F%20copy%20values.%20If%20it%20%22sometimes%20doesn't%20work%22%20then%20you%20are%20either%20doing%20something%20wrong%20or%20you%20have%20some%20kind%20of%20autocorrect%20enabled%20(if%20you%20use%20an%20apostrophe%20and%20a%20large%20number%26gt%3B%2015%20digits%2C%20Excel%20will%20treat%20it%20as%20an%20incorrect%20value%20and%20mark%20the%20cell%20with%20a%20warning%20hence%20it%20is%20this%20remark%20is%20neither%20personal%20nor%20critical.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20way%20to%20do%20this%20in%20bulk%20is%20to%20import%20values%20from%20a%20text%20file.%20Dare%20I%20say%20it's%20the%20only%20way%20out%20for%20most%20situations.%20Be%20sure%20to%20import%20the%20file%20and%20not%20just%20open%20it%2C%20as%20Excel%20treats%20the%20csv%20type%20like%20the%20native%20format%20and%20of%20course%20cuts%20large%20numbers%20to%2015%20digits.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20bottom%20line%20is%2C%20if%20you%20type%20a%20large%20numeric%20value%20into%20an%20Excel%20cell%20formatted%20as%20text%2C%20it%20will%20continue%20to%20be%20displayed%20in%20scientific%20notation%20as%20long%20as%20the%20cell%20is%20not%20wide%20enough.%20It's%20annoying%2C%20but%20a%20side%20effect%20of%20some%20of%20Excel's%20internal%20algorithms.%20If%20you%20just%20make%20the%20cell%20wider%20you%20will%20see%20the%20full%20value%20every%20time.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20pleasant%20task%20for%20most%20simple%20users%20like%20me%2C%20when%20you%20have%20nothing%20to%20do%20or%20don't%20want%20to%20do%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20my%20little%20knowledge%2C%20I%20cannot%20100%25%20verify%20whether%20all%20of%20this%20is%20the%20case.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWho%20am%20I%20already!%20...%20I%20know%20that%20I%20don't%20know%20anything.%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2316599%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2316599%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722750%22%20target%3D%22_blank%22%3E%40Nikolino%3C%2FA%3E%26nbsp%3B%20wrote%3A%20%60%60The%20moment%20you%20do%20this%2C%20the%20number%20is%20truncated%20to%2015%20digits%20and%20shown%20as%20exponential.%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHey%2C%20Niko%2C%20I%20think%20you%20responded%20to%20the%20wrong%20thread.%26nbsp%3B%20If%20you%20agree%2C%20you%20can%20delete%20your%20response%2C%20and%20I'll%20delete%20mine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENothing%20about%20Viz's%20problem%20has%20anything%20to%20do%20with%20trying%20to%20enter%20more%20than%2015%20significant%20digits.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHe%20is%20entering%20date%20and%20time%20perhaps%20in%20the%20form%202%2F1%2F2020%208%3A49%3A48%20AM.%26nbsp%3B%20At%20least%2C%20that%20is%20how%20column%20C%20appears%20to%20me%2C%20due%20to%20my%20regional%20settings.%26nbsp%3B%20(My%20date%20is%20in%20the%20form%20MDY.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2317023%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317023%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146717%22%20target%3D%22_blank%22%3E%40Joe%20User%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EIf%20the%20author%20thinks%20that%20the%20different%20behavior%20of%20the%20cells%20is%20not%20based%20on%20this%20(different%20formatting)%20and%20my%20comment%20for%20you%20means%20that%20it%20is%20bad%20%2F%20wrong%20%2F%20annoying%2C%20I%20of%20course%20take%20back%20my%20comment%20and%20apologize%20for%20the%20inconvenience.%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EYou%20do%20not%20need%20to%20delete%20yours%20as%20compensation.%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EComments%20are%20there%20to%20help%20further%2C%20to%20suggest%20possible%20solutions%2C%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3Eto%20reveal%20other%20solutions%20and%20so%20much%20more.%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EComments%20are%20not%20there%20to%20disturb%20or%20irritate%20or%20to%20fulfill%20any%20end%20in%20itself.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20understanding%20and%20patience%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2320579%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2320579%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%20wrote%3A%20%60%60thank%20you%20for%20the%20alternative%20solution%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%60%60%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20agree%20with%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E's%20SUMPRODUCT%20alternative%20to%20solve%20your%20problem%20with%20COUNTIFS.%20I%20suggest%20that%20you%20mark%20his%20response%20as%20%22best%22%20or%20%22answer%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIronically%2C%20you%20were%20correct%20in%20the%20first%20place%3A%20the%20original%20problem%20with%20COUNTIFS%20is%20indeed%20related%20the%20formatting%20defect%20that%20you%20stumbled%20across%20with%20your%20misguided%20rounding%20work-around.%20The%20formatting%20defect%20arises%20even%20without%20the%20explicit%20rounding.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20quibble%20with%20some%20details%20of%26nbsp%3BSergei's%20explanation%20of%20the%20issue.%20(See%20below.)%20But%20his%20SUMPRODUCT%20solution%20works%20because%20it%20treats%20the%20cell%20values%20in%20a%20consistent%20manner%2C%20in%20contrast%20to%20COUNTIFS.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConsider%20the%20date%20and%20time%20in%20C3%20(2%2F1%2F2020%208%3A49%3A48%20AM%2C%20which%20you%20format%20as%208%3A49).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20exact%20decimal%20representation%20of%20the%20binary%20approximation%20is%2043862.3679166666%2C%3CFONT%20color%3D%22%23FF0000%22%3E697%3C%2FFONT%3E7107524871826171875.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20the%20COUNTIFS%20condition%20that%20is%20effectively%20%22%26lt%3B%3D%22%26amp%3BC3%2C%20Excel%20replaces%20C3%20with%20the%20decimal%20representation.%20But%20Excel%20formats%20only%20up%20to%2015%20significant%20digits.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20should%20result%20in%20%22%26lt%3B%3D43862.3679166667%22.%20And%20if%20it%20did%2C%20COUNTIFS%20would%20correctly%20count%20that%20as%201.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20unfortunately%2C%20that%20particular%20binary%20value%20meets%20the%20conditions%20that%20evoke%20the%20formatting%20defect%2C%20to%20wit%3A%20the%20integer%20part%20is%20less%20than%2065536%2C%20and%20the%20remaining%20binary%20fraction%20can%20be%20represented%20in%2032%20bits%20or%20less%20(31).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20Excel%20formats%20the%20COUNTIFS%20condition%20as%20%22%26lt%3B%3D43862.3679166666%22%2C%20failing%20to%20round%20up%20the%2015th%20digit%20as%20it%20should%2C%20due%20to%20the%20formatting%20defect.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20since%20that%20is%20less%20than%20the%20value%20of%20the%20date%20and%20time%20in%20C3%2C%20COUNTIFS%20incorrectly%20does%20not%20count%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%26nbsp%3BSergei's%20SUMPRODUCT%2C%20the%20comparison%20expression%20is%20effectively%20C3%26lt%3B%3DC3.%20Of%20course%2C%20that%20is%20TRUE%2C%20no%20matter%20how%20Excel%20treats%20C3%20in%20that%20context.%20So%20SUMPRODUCT%20correctly%20counts%20that%20as%201.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFYI%2C%20there%20is%20another%20work-around%20that%20still%20uses%20COUNTIFS%2C%20which%20is%20more%20efficient%20than%20a%20SUMPRODUCT%20formula%2C%20namely%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DCOUNTIFS(%5BTime%5D%2C%22%26lt%3B%3D%22%26amp%3B%3CFONT%20color%3D%22%23FF0000%22%3ETEXT(%5B%40Time%5D%2C%22m%2Fd%2Fyyyy%20h%3Am%3As%22)%3C%2FFONT%3E%2C%5BUser%5D%2C%5B%40User%5D%2C%5BDate%5D%2C%5B%40Date%5D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20that%20case%2C%20COUNTIFS%20converts%20the%20string%20%222%2F1%2F2020%209%3A3%3A59%22%20to%20the%20correct%20binary%20approximation%20internally.%20Then%20it%20treats%20the%20converted%20value%20and%20the%20value%20in%20C3%20consistently%20for%20the%20comparison.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20do%20not%20recommend%20it%20because%20the%20correctness%20of%20%22m%2Fd%2Fyyyy%22%20depends%20on%20regional%20options.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20another%20date%20format%20that%20someone%20claims%20is%20%22universal%22.%20I%20don't%20remember%20what%20it%20is%2C%20off-hand.%20No%20matter%3A%20I%20do%20not%20recommend%20it%2C%20since%20I%20cannot%20vet%20the%20claim.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20choose%20the%20SUMPRODUCT%20alternative%20myself.%20KISS!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%20wrote%3A%20%60%60Excel%20works%20by%20default%20with%2015%20digits%20and%20many%20functions%20ignore%20extra%20digits%2C%20but%20some%20work%20in%20background%20with%2017%20digits%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EActually%2C%20Excel%20works%20with%20the%20%3CU%3E%3CEM%3Efull%20binary%20precision%3C%2FEM%3E%3C%2FU%3E%20by%20default.%20That%20is%20the%20cause%20of%20most%20arithmetic%20anomalies.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExcel%20never%20%22works%20in%20the%20background%20with%2017%20digits%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20it%20is%20true%20that%20binary%20values%20can%20be%20approximated%20with%2017%20significant%20digits%2C%20with%20no%20loss%20of%20precision%20when%20converting%20back%20to%20binary.%20So%20Excel%20does%20represent%20binary%20values%20with%20up%20to%2017%20significant%20decimal%20digits%20when%20a%20workbook%20is%20saved%20to%20an%20XML%20file%2C%20which%20include%20%22xlsx%22%20and%20%22xlsm%22%20files.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExcel%20never%20%22stores%2015%20digits%20of%20precision%22%2C%20as%20many%20articles%20state%20incorrectly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20Excel%20does%20format%20only%20up%20to%2015%20significant%20digits.%20And%20that%20is%20what%20causes%20the%20problem%20with%20Viz's%20COUNTIFS%20formulas%2C%20in%20conjunction%20with%20the%20formatting%20defect%20documented%20in%20KB%20161234.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20also%20true%20that%20for%20%3CEM%3E%3CU%3Esome%3C%2FU%3E%3C%2FEM%3E%20comparisons%2C%20Excel%20rounds%20operands%20internally%20to%2015%20significant%20digits%20just%20for%20the%20purpose%20of%20the%20comparison.%20(And%20for%20%3CU%3E%3CEM%3Esome%20other%3C%2FEM%3E%3C%2FU%3E%20comparisons%2C%20Excel%20compares%20the%20full%20binary%20precision.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321054%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321054%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530769%22%20target%3D%22_blank%22%3E%40Viz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat's%20very%20interesting%2C%3C%2FP%3E%3CP%3ESo%20the%20essence%20of%20this%20rounding%20issue%20seems%20to%20be%20for%20numbers%20like%20x%3D43863.89142%2C%3C%2FP%3E%3CP%3E%3DCOUNTIF(x%2Cx)%3CBR%20%2F%3E%3D%26gt%3B%201%3C%2FP%3E%3CP%3Eas%20expected%2C%20but%3C%2FP%3E%3CP%3E%3DCOUNTIF(x%2C%22%3D%22%26amp%3Bx)%3CBR%20%2F%3E%3D%26gt%3B%200%20%3F!%3C%2FP%3E%3CP%3EA%20safer%20approach%20is%20to%20convert%20date%2Ftimes%20to%20integers%20for%20comparisons%20by%20multiplying%20by%2024*60*60.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321198%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321198%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288074%22%20target%3D%22_blank%22%3E%40lori_m%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20I%20remember%20such%20behaviour%20is%20for%20all%20%3CDO%3EIF()%20functions%2C%20e.g.%26nbsp%3B%3DSUMIF(x%2C%22%3D%22%26amp%3Bx%2C%20x)%20%3D%26gt%3B0%20vs%3C%2FDO%3E%3C%2FP%3E%0A%3CP%3E%3DSUMIF(x%2Cx%2Cx)%20%3D%26gt%3Bx%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321325%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321325%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20and%20in%20general%20any%20functions%20or%20operators%20that%20take%20text%20type%20inputs%20will%20be%20similarly%20affected%20since%26nbsp%3Bexpressions%20such%20as%20%22%22%26amp%3Bx%20get%20incorrectly%20rounded.%20The%20SUMPRODUCT%20workaround%20you%20suggest%20takes%20numeric%20inputs%20and%20so%20is%20not%20affected.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2323080%22%20slang%3D%22en-US%22%3ERe%3A%20Serious%20bug%20with%20certain%20decimal%20numbers%3A%20Countifs%20and%20Roundup%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2323080%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288074%22%20target%3D%22_blank%22%3E%40lori_m%3C%2FA%3E%26nbsp%3B%20wrote%3A%20%60%60A%20safer%20approach%20is%20to%20convert%20date%2Ftimes%20to%20integers%20for%20comparisons%20by%20multiplying%20by%2024*60*60%60%60.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20that%20would%20not%20work%20with%20COUNTIF%5BS%5D%2C%20at%20least%20not%20without%20a%20helper%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20would%20need%20to%20array-enter%20an%20expression%20of%20the%20form%3C%2FP%3E%3CP%3ECOUNTIFS(%24C%243%3A%24C%24102*86400%2C%20%22%26lt%3B%3D%22%20%26amp%3B%20C3*86400).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20does%20not%20work%20because%20COUNTIF%5BS%5D%20requires%20a%20range%20%3CEM%3Eper%20se%3C%2FEM%3E%20for%20the%20first%20parameter.%20It%20does%20not%20accept%20arrays.%20(The%20help%20page%20is%20wrong!)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have a file that had time upto the seconds level. Some of these numbers had 99999.. after the fifth decimal digit. And all these numbers seem to throw a major bug.

I wanted to find out how many entries were made on or before the current time. Shocking excel returned the answer as zero for those times or numbers with 99 in the sixth decimal point onwards (which is impossible because the time is already in the array).

 

I even tried rounding those numbers to five decimal points but it didn't round.

OpenOffice Calc, Google Sheets and Zoho sheets does not seem to create any such trouble. I have attached the file.

 

Any thoughts?

16 Replies

@Viz 

Try using MROUND(..., 1/86400)

(1 second = 1/86400 of a day)

 

S0357.png

@Hans Vogelaar  wrote: ``Try using MROUND(..., 1/86400)``

 

I think that is ill-advised.

 

Consider Sheet1!B4.  It display 8:49, but the actual value is 2/1/2020 8:49:48.  (I write dates in the form MDY.)

 

=ISNUMBER(MATCH(MROUND(B4, 1/86400), B4, 0)) returns FALSE(!).

 

(FYI, we could write "0:0:1" with double-quotes instead 1/86400.)

 

The reason is:  the binary result from MROUND does not match the binary representation of 2/1/2020 8:49:48.  In fact, MROUND fails for more than 25% of the values in column B.

 

An exact binary match is important for lookups, for example.

 

In contrast....

 

=ISNUMBER(MATCH(INT(B4)+TEXT(B4,"h:m:s"), B4, 0)) returns TRUE for all values in column B.

 

-----

 

Caveat: INT(B4)+TEXT(B4,"h:m:s") works for constants that are accurate to the second.

 

And it works for calculated date and time that results in less than 23:59:59.500.

 

However, if date and time values might be accurate to the 1/10 second (or less), the following rounds to the second more reliably:

 

INT(B4)+TEXT(MOD(B4,1),"[h]:m:s.000")

 

The reason is:  Excel rounds to the second when formatting to the hour, minute or second.

 

Consequently, for example, 2/1/2020 23:59:59.6 displays as 2/2/2020 0:00:00.

 

But INT(B4)+TEXT(B4,"h:m:s") would incorrectly result in 2/1/2020 0:00:00.

@Viz 

I think there are two separate issues, and it is unclear if the issue that you focused on is truly important for your purposes -- although it is interesting curiosity.

 

-----

 

Yes, Excel has a formatting defect that causes 43863.89142 to be displayed as 43863.8914199999, for example.

 

(MSFT used to document the defect in KB161234.  But I cannot find that document or the equivalent online anymore.  No matter.  The KB description was inaccurate, anyway.)

 

The defect is specific to Excel.  It has nothing to do with the 64-bit binary floating-point standard.  That is why you do not see it in other applications.

 

And the formatting defect is not limited to ROUNDUP.  The formatting defect arises with relatively few binary values that meet very specific conditions.  (I can explain, if you wish.  It is TMI for most people.)

 

Moreover, the effect of the formatting defect can be confusing because when we enter 43863.89142, initially it has the binary value of 43863.89142, even though it appears to be 43863.8914199999.  But if we edit the cell, it changes to the binary value of 43863.8914199999, which is different.

 

For example, initially =ISNUMBER(MATCH(VALUE("43863.89142"), { 43863.89142 }, 0)) returns TRUE, even though it appears to be =ISNUMBER(MATCH(VALUE("43863.89142"), { 43863.8914199999 }, 0)).

 

But if we select the cell and press f2, then Enter, the formula returns FALSE.

 

OTOH, if we have =VALUE("43863.89142") in A1, =COUNTIF(A1, "="&43863.89142) always returns zero because COUNTIF sees the string "=43863.8914199999".

 

The only work-around that I know is to replace such constants with expressions like VALUE("43863.89142"), ROUND("43863.89142",5), A1+"43863.89142", etc.

 

The key is to enter such numbers in double-quotes in an arithmetic expression, when you encounter the formatting defect.

 

-----

 

But the real question is:  why are you using ROUNDUP(B4,5), in the first place?

 

In Sheet1, the date and time constants in column B are already accurate to the second.  There is no need to round them.

 

And if there is a need (for example, for calculated date and time values), rounding to 5 decimal places is the wrong way to do it.

 

Instead, you might use one of the following, depending on your requirements.

 

TEXT(B4, "m/d/yyyy h:m:s")

or

--TEXT(B4, "m/d/yyyy h:m:s")

or

INT(B4)+TEXT(B4,"h:m:s")

or

INT(B4)+TEXT(MOD(B4,1),"[h]:m:s")

 

If you provide the original use of COUNTIFS that led to the problem, we can be more specific.

 

I think what you posted in your attachment is your attempts to understand and work around the original problem.  I "cannot see the forest for the trees".

@Joe User 


The only work-around that I know is to replace such constants with expressions like VALUE("43863.89142"), ROUND("43863.89142",5), A1+"43863.89142", etc.

 

The key is to enter such numbers in double-quotes in an arithmetic expression, when you encounter the formatting defect.

Interesting. I've never sever such a workaround before. Will keep it in mind.

 

 

@Joe User , FYI

Classic Diego Oppenheimer post which explains floating point precision is here Understanding Floating Point Precision, aka “Why does Excel Give Me Seemingly Wrong Answers?” - Micr...

 

Microsoft restructured documentation with introducing of docs.microsoft.com, articles as KB161234 are here. With some updates where applicable. In particular this one is Floating-point arithmetic may give inaccurate result in Excel - Office | Microsoft Docs

@Viz 

In addition, Excel works by default with 15 digits and many functions ignore extra digits, but some work in background with 17 digits. More about that is here 17 or 15 digits of precision - Excel Tips - MrExcel Publishing

 

For this particular case if use

=SUMPRODUCT( ($C$1:$C$11<=C4)*($B$1:$B$11=B4))

instead of COUNTIFS() it returns correct result.

Thank you for a detailed response, @Joe User and thank you for the alternative solution @Sergei Baklan 

 

I had a list of end users with various entry times and I had to count how many times an user has done entry up to a given point. So, I wanted to apply this: =Countifs([Time],"<="&[@Time],[User],[@User])

 

That is when I noticed that for some of the entries I was getting wrong answers. Roundup was more of a workaround I attempted to fix the problem.

I didn't realise this issue existed in MS Excel. Thank you for helping me understand the bug.

@Sergei Baklan  wrote:

``Classic Diego Oppenheimer post which explains floating point precision``

and

``articles as KB161234 are here. [....] In particular this one is``

 

 

First, as I stated clearly previously, this formatting defect has nothing to do with 64-bit binary floating-point precision.

 

To demonstrate that fact, note that when we enter 43863.89142, Excel incorrectly displays 43863.8914199999, but VBA correctly displays 43863.89142.

 

And in fact, the binary approximations are different.  The following shows the exact decimal representation of the two binary approximations:

 

43863.89142:

43863.8914199999,9992549419403076171875

 

43863.8914199999:

43863.8914199998,98062087595462799072265625

 

(I use period for the decimal point and comma to demarcate the first 15 significant digits.)

 

-----

 

Second, the MSFT article that you cite is a retitling of KB 78113, not KB 161234.

 

But aha! I just stumbled across an archived version of KB 161234 at Microsoft KB Archive/161234 - BetaArchive Wiki .  For posterity, it reads, in part:

 

``when you type or calculate a number between 32,768 and 65,535 that contains a decimal portion of .848, the number is evaluated and displayed in the formula bar with a decimal portion of .8479999999. [....] Microsoft has confirmed this to be a problem``

 

That KB description is incomplete.  The formatting defect is not limited to the list Excel versions (5.0, 95 and 97).  Obviously, it applies to the latest Excel versions as well.  And the emphasis should be on constants and calculations that we explicitly round.

 

(Obviously, unrounded calculations with decimal fractions are susceptible to the anomalies of binary floating-point arithmetic, which can result in unexpected decimal fraction digits.)

 

And I take issue with the statement:  ``.848 [...] is evaluated [...] with a decimal portion of .8479999999``.  As I noted previously, when we enter 43863.89142, initially the value that appears to be 43863.8914199999 has the binary approximation of 43863.89142.  It is changed to ("evaluated as") the binary approximation of 43863.8914199999 only after we edit the line in the Formula Bar.

 

More importantly, the formatting defect is not limited to that integer range and that decimal fraction.  For example, for that integer range, other 3-digit fractions are 0.098, 0.223, 0.348, 0.473, 0.598, 0.723 and 0.973 as well as 0.848.

 

And @Viz's examples include 5-digit fractions in that integer range; for example, 43863.89142.

 

(Caveat: The following is TMI for most people.)

 

It is difficult to predict the decimal values that evoke the formatting defect.

 

And it is difficult for me to explain the conditions that evoke the formatting defect without resorting to the details of the binary representation.  Those conditions are:

 

1. The integer part of the number is 65535 or less.  If the integer part is zero, the decimal fraction must exceed 0.5.  And

 

2. The binary approximation of the decimal fraction can be represented in 32 bits; that is, all the bits to the right are zero.  And

 

3. The 16th significant digit of the exact decimal representation of the binary approximation is 5 or more.

 

I'm sure the 3rd condition is not explicit in the Excel implementation.  But we notice a formatting defect only when the 15th significant digit should be rounded up, and it is not.

@Hans Vogelaar 

 

Thank you, Hans.

 

It almost sorted the problem. But there were still a few numbers that it couldn't fix. As Joe mentioned, there seems to be some inherent problem in certain odd cases.

The solution that Sergei gave to use sumproduct in place of Countif fixed the problem.

@Viz 

After a lot of rummaging around on Google, I came to this result.

The short answer is, you can't edit your numbers the way you want after you've entered the numeric value and hit enter. The moment you do this, the number is truncated to 15 digits and shown as exponential.

 

This is not a bug, it is a function.

 

Everything you do after that uses the truncated value, so no formatting trick is helpful. However, you can use the “Text to columns“ option to convert the exponential notation to text (click on the column heading, click “Text to data“ then click Delimited, Next uncheck all delimiting boxes, select “Text in Column data format "And then from" Finish ") to convert the values ​​into text and immediately display them as a 15-digit number. But it will only be 15 digits so if you had a longer number the pause is lost.

 

To have the number in the worksheet exactly as you entered it, you need to save it as text. So you have to prepend an apostrophe or format cells as text before you can enter / copy values. If it "sometimes doesn't work" then you are either doing something wrong or you have some kind of autocorrect enabled (if you use an apostrophe and a large number> 15 digits, Excel will treat it as an incorrect value and mark the cell with a warning hence it is this remark is neither personal nor critical.

 

Another way to do this in bulk is to import values ​​from a text file. Dare I say it's the only way out for most situations. Be sure to import the file and not just open it, as Excel treats the csv type like the native format and of course cuts large numbers to 15 digits.

 

The bottom line is, if you type a large numeric value into an Excel cell formatted as text, it will continue to be displayed in scientific notation as long as the cell is not wide enough. It's annoying, but a side effect of some of Excel's internal algorithms. If you just make the cell wider you will see the full value every time.

 

A pleasant task for most simple users like me, when you have nothing to do or don't want to do anything.

 

With my little knowledge, I cannot 100% verify whether all of this is the case.

 

Who am I already! ... I know that I don't know anything.

Nikolino

 

 

@Nikolino  wrote: ``The moment you do this, the number is truncated to 15 digits and shown as exponential.``

 

Hey, Niko, I think you responded to the wrong thread.  If you agree, you can delete your response, and I'll delete mine.

 

Nothing about Viz's problem has anything to do with trying to enter more than 15 significant digits.

 

He is entering date and time perhaps in the form 2/1/2020 8:49:48 AM.  At least, that is how column C appears to me, due to my regional settings.  (My date is in the form MDY.)

 

@Joe User 

If the author thinks that the different behavior of the cells is not based on this (different formatting) and my comment for you means that it is bad / wrong / annoying, I of course take back my comment and apologize for the inconvenience.

You do not need to delete yours as compensation.

 

Comments are there to help further, to suggest possible solutions,

to reveal other solutions and so much more.

Comments are not there to disturb or irritate or to fulfill any end in itself.

 

Thank you for your understanding and patience

 

 

Nikolino

I know I don't know anything (Socrates)

@Viz  wrote: ``thank you for the alternative solution @Sergei Baklan``


I agree with @Sergei Baklan's SUMPRODUCT alternative to solve your problem with COUNTIFS. I suggest that you mark his response as "best" or "answer".

 

Ironically, you were correct in the first place: the original problem with COUNTIFS is indeed related the formatting defect that you stumbled across with your misguided rounding work-around. The formatting defect arises even without the explicit rounding.

 

I quibble with some details of Sergei's explanation of the issue. (See below.) But his SUMPRODUCT solution works because it treats the cell values in a consistent manner, in contrast to COUNTIFS.

 

Consider the date and time in C3 (2/1/2020 8:49:48 AM, which you format as 8:49).

 

The exact decimal representation of the binary approximation is 43862.3679166666,6977107524871826171875.

 

For the COUNTIFS condition that is effectively "<="&C3, Excel replaces C3 with the decimal representation. But Excel formats only up to 15 significant digits.

 

That should result in "<=43862.3679166667". And if it did, COUNTIFS would correctly count that as 1.

 

But unfortunately, that particular binary value meets the conditions that evoke the formatting defect, to wit: the integer part is less than 65536, and the remaining binary fraction can be represented in 32 bits or less (31).

 

So Excel formats the COUNTIFS condition as "<=43862.3679166666", failing to round up the 15th digit as it should, due to the formatting defect.

 

And since that is less than the value of the date and time in C3, COUNTIFS incorrectly does not count that.

 

With Sergei's SUMPRODUCT, the comparison expression is effectively C3<=C3. Of course, that is TRUE, no matter how Excel treats C3 in that context. So SUMPRODUCT correctly counts that as 1.

 

-----

 

@Sergei Baklan  wrote: ``Excel works by default with 15 digits and many functions ignore extra digits, but some work in background with 17 digits``

 

Actually, Excel works with the full binary precision by default. That is the cause of most arithmetic anomalies.

 

Excel never "works in the background with 17 digits".

 

But it is true that binary values can be approximated with 17 significant digits, with no loss of precision when converting back to binary. So Excel does represent binary values with up to 17 significant decimal digits when a workbook is saved as an XML file, which includes "xlsx" and "xlsm" files.

 

Excel never "stores 15 digits of precision", as many articles state incorrectly.

 

But Excel does format only up to 15 significant digits. And that is what causes the problem with Viz's COUNTIFS formulas, in conjunction with the formatting defect documented in KB 161234.

 

It is also true that for some comparisons, Excel rounds operands internally to 15 significant digits just for the purpose of the comparison.  That is the case with comparison operators ("=", "<", etc) and with COUNTIF[S].

 

(But interestingly, the internal rounding is not susceptible to the formatting defect.)

 

(And for some other comparisons, Excel compares the full binary precision. That is the case with lookup functions like MATCH, VLOOKUP, etc, for example.)

 

 

@Viz 

That's very interesting,

So the essence of this rounding issue seems to be for numbers like x=43863.89142,

=COUNTIF(x,x)
=> 1

as expected, but

=COUNTIF(x,"="&x)
=> 0 ?!

A safer approach is to convert date/times to integers for comparisons by multiplying by 24*60*60.

 

@lori_m 

As I remember such behaviour is for all <DO>IF() functions, e.g. =SUMIF(x,"="&x, x) =>0 vs

=SUMIF(x,x,x) =>x 

@Sergei Baklan 

Yes, and in general any functions or operators that take text type inputs will be similarly affected since expressions such as ""&x get incorrectly rounded. The SUMPRODUCT workaround you suggest takes numeric inputs and so is not affected.