I have some random number x. It can be 222.1245646 or 3.141562652. How should I show this number to 5 decimal numbers ? I cant use this:
N[x, 5]
because it shows 5 digits(222.12 or 3.1415).
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have some random number x. It can be 222.1245646 or 3.141562652. How should I show this number to 5 decimal numbers ? I cant use this:
N[x, 5]
because it shows 5 digits(222.12 or 3.1415).
Use NumberForm[].
This will display number 1.2345678 with 3 precise digits and 4 digits to the right of the decimal:
NumberForm[1.2345678, {3, 4}]
1.2300
You can adjust the second argument to suit your needs. Maybe like this:
NumberForm[1.2345678, {99, 5}]
1.23457
7 is at the end instead of 6 because of rounding.