I have a problem concerning the number of decimal places in numerical output.

Given the output


I want the output to 10 decimal places only; that is


I used


but I didn't get the answer I wanted.

Please help me.

  • $\begingroup$ See: Change the format of numbers. $\endgroup$ – dionys Oct 20 '16 at 10:32
  • 2
    $\begingroup$ If you read the documentation for N, it states that "With machine-precision input, the results are always machine precision". You probably want to use NumberForm to change the way the number is displayed rather than N to change the precision. $\endgroup$ – MikeLimaOscar Oct 20 '16 at 10:33
  • $\begingroup$ thank you very much. I do it. But what actually meaning "With machine-precision input," it is from computer? $\endgroup$ – munirah Oct 20 '16 at 10:58
  • 2
    $\begingroup$ Basically unless you specify more than about 16 significant digits in a number containing a decimal point Mathematica will assume you want a machine precision number (effectively an IEEE double) and calculations involving that number will be done with machine precision. Mathematica can also use exact numbers (e.g. rationals) and arbitrary precision numbers, e.g. 1.2345`30 where the precision is tracked during calculations. Perhaps a good place to start is Exact and Approximate Results $\endgroup$ – MikeLimaOscar Oct 20 '16 at 11:12
  • $\begingroup$ thank you @MikeLimaOscar for good ecplaination $\endgroup$ – munirah Oct 20 '16 at 18:13

You are probably looking for NumberForm.

x = 0.00578493736389;


x // FullForm


Precision @ x


The evaluations given above are have been done to show you some tools for seeing what you are dealing with. Now let's apply NumberForm.

NumberForm[x, {∞, 10}]


NumberForm can be tricky to use. Read the documentation article on it fully and carefully. In particular, keep in mind that it only affects the the way a number is displayed. It does not affect the internal representation of the number.

  • $\begingroup$ thanks a lot for very useful comment $\endgroup$ – munirah Oct 20 '16 at 18:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.