in reply to Re^8: subtraction issue
in thread subtraction issue

# easy to come up with one that takes many digits to express

I eventually realized that if I increased the precision to 4000 bits (which is overkill) I would uncover values that require more digits:
3 / (3566377 ** 47) 0x1.7f1efda69bf79p-1022 3.32997129135359853606999222704654320128433273140834060375717919336765 +633480476074271117603537227797195965402328724231998706388357189066271 +703262139769146889312212556637321188791634569121935603887648273923627 +861919579821592345988060019740748868666186270141425088422184655360375 +823488548150443554012541921413793579099043424106801075148744029407167 +466158885097383679527382985052678222745861830039508807658877054796192 +051679570983765540503801105423327949689320479645855971334458658126010 +779989548774133737798898372623216628041645234343358029716664630265490 +827644527215647502548686221202499548660963335999734105043799288928491 +124484505682527752151459948594916997840488088218758704043473479179413 +158767647452761573740845092915600087271621454476644430542364716529846 +19140625e-308
This(excluding "." and "e-308") is 767 digits.

Cheers,
Rob

Replies are listed 'Best First'.
Re^10: subtraction issue
by syphilis (Archbishop) on Jan 29, 2017 at 09:14 UTC
    Eventually, I googled this.

    Looks lie it addresses what we've been fiddling with.

    Cheers,
    Rob

      yes, that's exactly where I was trying, rather ineffectually, to get to. Thank for finding that.

        ... As promised, my manual manipulation of FixedPoint (arbitrary length strings of digits) ...

        __RESULTS__ ------------------------------------------------------ ulp(1) = 0.0000000000000002220446049250313080847263336181640625 1+ulp(1) = 1.0000000000000002220446049250313080847263336181640625 ------------------------------------------------------ ---------------------------------------- (1+ulp(1))*2**-1022 = 0.00000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000002225073858507201877155878558578948240 +788008848683704195613130031211968860399600696529790429221262885863903 +701367028190801717129607271191035512722741317515219905574004313880456 +780323337753988163917738732895924607422927011307805381339708165336129 +644744952978952121897909078385258336590185178961879988515042751478263 +607602168043622031129270045483207396484571310391222596393560832244062 +389690727689018671705454927517398658932481040173822832825124579506565 +573819103800864691161582871998970864729322144979697154670672039979199 +080916034762598038599542473984767886118009507251154376238960371621517 +172981601154460435953128432540644193864532490538913779568091580479240 +509922741385427494262054264040883983691918741817298779334027924276754 +4565229087538682506419718265533447265625 FixedPoint: 1 = Digits before the fixed decimal point FixedPoint: 1074 = Total digits the fixed decimal point FixedPoint: 308 = Location of first significant digit (nt +h digit after decimal point) FixedPoint: 767 = Number of significant digits Double: 2.2250738585072019e-308 HexFloat: +0x1.0000000000001p-1022 DecFloat: +0d1.0000000000000002p-1022 Math: 308 = should start at ceil(-log10(x))-th digi +t after decimal point Math: 1074 = total number of digits after decimal sh +ould be the lowest power of two = ceil(-log2(ulp(x))) Math: 767 = Number of significant digits

        So what I said poorly as "it takes n fixed-point decimal digits to exactly represent an n-bit fixed-point fractional binary number" could have been better phrased: "if the smallest power of two exactly represented in a floating-point number is -n, it takes n decimal digits after the fixed decimal point to exactly represent that same number." In the example of nextUp(1), the smallest power of two is -52, so it takes 52 decimal digits after the fixed decimal point to exactly represent it. In the example of nextUp(POS_NORM_SMALLEST) = 2**-1022 + 2**-1074, it takes 1074 digits after the fixed decimal point to exactly represent it.

        Thanks for this interesting diversion.

        update: removed duplicate end-code tag