I have the following set of equations:
xs = 9295050963679385441209;
ys = 10721945986215692199666;
x = xs - 10000;
exponent = 0.666451549104308964``18;
xs1gt = Power[xs,exponent];
Which should produce ~437295921404696.997750975489799605.
If I naively print xs1gt
, I get this:
4.372959214046970*10^14
I looked for solutions on StackExchange, and I found the How to avoid the scientific notation in output? thread. Unfortunately, none of the solutions proposed there worked:
AccountingForm[xs1gt, 33]
DecimalForm[xs1gt, {15, 18}]
N[xs1gt, 33]
NumberForm[xs1gt, 33]
NumberForm[xs1gt, 33, ExponentFunction->(Null&)]
NumberForm[xs1gt, 33, ScientificNotationThreshold->{-Infinity, Infinity}]
Outputs:
437295921404697.0
437295921404697.000000000000000000
4.372959214046970*10^14
4.372959214046970*10^14
437295921404697.0
437295921404697.0
I searched high and low for alternatives, and I stumbled upon InputForm and SetPrecision, which finally gave me satisfactory results:
InputForm[xs1gt]
SetPrecision[xs1gt, 33]
Outputs:
4.372959214046969977509754897996045`16.295988813986288*10^14
4.37295921404696997750975489799605*^14
Now my question is why didn't the other approaches, i.e. AccountingForm
, DecimalForm
and NumberForm
, produce a similar result with 33 significant figures of precision (15 digits and 18 decimals)? I am especially confused by DecimalForm
not having worked the way I expected.
*Form
wrapper seems not override the precision of the number and uses the precision as a limit on the number of sig figs, with excess digits being padded with zero if necessary. It is similar to the behavior ofRealDigits
and fits with the Mathematica notion ofPrecision
. IsDecimalForm[SetPrecision[xs1gt, 33], {33, 18}]
a good enough workaround? $\endgroup$exponent
. Try these two modifications:exponent = SetAccuracy[0.666451549104308964, 50]
(or use the double backtick form) andDecimalForm[xs1gt, {33, 18}]
. Does this give the desired result? $\endgroup$