Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to simply add ending zeros to a decimal number?

For example: 2.1 should be 2.10 (precision till 1/100), 2 should be 2.00, etc.

I've tried looking into

digits = RealDigits[3.1,10,3][[1]]

which gives {3, 1, 0}, and using this, the impressively complicated form

Row@{digits[[1]], ".", Sequence @@ Rest@digits}

gives the desired result. But this is enormously complicated, and I was wondering whether there exist another (easier) method?

Thanks for all help, as always!

share|improve this question

closed as off-topic by Mike Honeychurch, Sjoerd C. de Vries, Artes, belisarius, m_goldberg Nov 21 '13 at 2:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Mike Honeychurch, Sjoerd C. de Vries, Artes, belisarius, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

    
You need NumberForm, see related question Annoying display truncation of numerical results. –  Artes Nov 20 '13 at 16:43
    
SetPrecision[2.1, 3] might work for you too. –  Sjoerd C. de Vries Nov 20 '13 at 21:35

1 Answer 1

up vote 1 down vote accepted

Take a look at Precision, Accuracy and this tutorial.

To tell the system that 2.10 is valid to 3 digits in total, use 2.1`3.

share|improve this answer

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