New to Mathematica (ver 9). Trying to use numerical constants with about 20 decimal places in functions like N, but it keeps converting them to 6 decimal places. I know this has to be an easy thing to do, but cannot find it anywhere in the docs.
Beware of the decimal point! It will kill your high precision.
If you enter
you get 7.3890560989306502272.
But if you enter
You get only 7.38906.
If you need to use fractional amounts rationalize them fiirst
If you want a high precision estimate for 2^2.125.
N[2^Rationalize[2.125, 0], 20]
.The 0 in Rationalize makes sure the decimal is rationalized completely, not just substituted by an approximation.
Perhaps an example of what you are doing would help. The default display form for machine precision numbers is 6 places, but the remaining digits are still there. If you are doing a computation with both high precision numbers and machine precision numbers then the result will generally be machine precision unless there are in fact no machine precision numbers... and even then, depending on the calculation, the resulting precision may be less than that of the input numbers. E.g. (note the use of FullForm to show how many digints are actually there.
In:= N[Pi, 30] + N[Pi] // FullForm
In spite of using a 30 digit precisin, when combined with a machine precision number the result is Machine precision
Without the FullForm only 6 digits are shown
In:= N[Pi, 30] + N[Pi]
Here's a simplified example:
How do I get it to return more digits?
Please reread both my and Marvin's responses carefully.
First: The formatting of output cells is, by default, set so that only 6 digits are displayed for machine precision numbers. The full number of digits are still saved internally--and in fact they are in the cell itself, but only a portion of them are displayed. But you can change the number of digits displayed in the Preferences but going to the Appearance/Numbers/Formatting subtab.
If you do not want to do this you can use FullForm to display the exact number of digits.
Results with a number of digits generated by arbitrary precision arithmetic will display their full set of digits. Eg
N[Pi, 40] + 2 x
The expression that you gave will not give 20 digits of precision as it starts with a machine precision number.
In:= InputForm[N[2 1.23456789, 20]]
You cannot get more precision out than what you put in and may get less, depending on the calculations you do with the numbers.
You can also use NumberForm to show as many digits as you wish, but no more than are actually there. For example this is a machine precision number and so, even though there is a 30 there, only the number of digits that are actually there will be shown:
You can read more about some of these things here:
Thank you, this was exactly what I was looking for. I knew there had to be a simple solution.