# How can I control the number of digits to right of the decimal point? [duplicate]

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

Given the output

0.00578493736389


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

0.0057849374


I used

N[exp,n]


but I didn't get the answer I wanted.

• – dionys Oct 20 '16 at 10:32
• 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. – MikeLimaOscar Oct 20 '16 at 10:33
• thank you very much. I do it. But what actually meaning "With machine-precision input," it is from computer? – munirah Oct 20 '16 at 10:58
• 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.234530 where the precision is tracked during calculations. Perhaps a good place to start is Exact and Approximate Results – MikeLimaOscar Oct 20 '16 at 11:12
• thank you @MikeLimaOscar for good ecplaination – munirah Oct 20 '16 at 18:13

You are probably looking for NumberForm.

x = 0.00578493736389;


0.00578494

x // FullForm


0.00578493736389

Precision @ x


MachinePrecision

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}]


0.0057849374

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.

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