# Way to improve “show me this decimal number to M places, don't use scientific notation”?

The best way I can come up with to say "show me this fraction as a decimal number to M places, don't use scientific notation" is:

NumberForm[N[1/998001,2994],ExponentFunction->(Null&)]


It seems like that's an awful lot of typing for a very simple request.

Is it possible to say it more concisely?

-
I think that is the canonical way, but that doesn't mean there isn't something more terse. – Mr.Wizard Jan 26 '12 at 19:42
I don't think you can avoid it altogether. But if you find yourself doing it a lot, you can always use SetOptions... – Andrzej Kozlowski Jan 26 '12 at 19:53
I can't use any of these values to plot becasue their Head changes to NumberForm and graphs don't understand this form. I need to plot and have the tooltip show decimal form, any suggested alterations to the above to make it work? – Lara Jordan Apr 10 '13 at 7:24

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/320
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/9980012994]
Out[2]//AccountingForm= 0.0000010020030040050060070080090100110120130140...


However, be aware that AccountingForm uses parentheses for negative numbers:

AccountingForm[-1/9980012994]
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[250] 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.

-
I also thought of AccountingForm (and RealDigits), but I think the negative numbers are an issue. – Mr.Wizard Jan 26 '12 at 19:59
@Mr.Wizard Yes, but I also noticed that it uses () for negative numbers, which could be used to distinguish if one were to use this only for quick visual checking – R. M. Jan 26 '12 at 20:01
I am voting for this since I think AccountingForm comes closest. – Mr.Wizard Jan 26 '12 at 21:16
Might just use N[...,m]. Check difference between Log[220] and N[Log[2],20]. The former will lose a digit. (Might not be important for the purposes at hand, though.) – Daniel Lichtblau Jan 27 '12 at 0:09
Can avoid () for negative numbers with AccountingForm[-1/9980012994, NumberSigns -> {"-", ""}], although that may exceed the "awful lot of typing" limit... – KennyColnago Sep 3 '15 at 16:41

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`.

-