Way to improve "show me this decimal number to M places, don't use scientific notation"?
You can express any fraction/number to arbitrary decimal places by using a backtick followed by number of digits required. For example:
In[1]:= 4/3`20
Out[1]= 1.3333333333333333333
This is the same as N[4/3, 20]
. Now combine this with AccountingForm
, which never uses scientific notation to get the output that you desire.
AccountingForm[1/998001`2994]
Out[2]//AccountingForm= 0.0000010020030040050060070080090100110120130140...
However, be aware that AccountingForm
uses parentheses for negative numbers:
AccountingForm[-1/998001`2994]
Out[3]//AccountingForm= (0.00000100200300400500600700800901001101201301401501601....
Daniel Lichtblau has a good point that although using `
instead of N
might be shorter in this case, in general, it might not give the same result — for example, compare the digits of Log[2`50]
and N[Log[2],50]
. You'll see that they differ in the last couple of digits. However, for small use cases, the difference might be insignificant.
You could always set $Post
to have this happen automatically.
format[x_Real] := NumberForm[x, ExponentFunction -> (Null &)];
format[x_] := x;
$Post = format;
Now,
N[1/998001, 50]
returns
0.0000010020030040050060070080090100110120130140150160170
Even better, $Post
is applied at display time, thus
Head[%]
returns Real
.