Message Boards Message Boards

[✓] Get two significant digits to the right of the decimal point?

GROUPS:

N[x,3] gives me 1.10 and 0.982, when what I want is 0.98. How do I get two and only two digits to the right of the decimal point?

POSTED BY: Nelson Zink
Answer
1 month ago
N[x, {Infinity, 2}]

provided x is not of machine precision (MachinePrecision).

POSTED BY: Michael Rogers
Answer
1 month ago

Thanks.

POSTED BY: Nelson Zink
Answer
1 month ago

If it is the formatting that is of interest rather than the underlying value, could use DecimalForm[0.982,{Infinity,2}] This is new in version 11.2 I think, but there are ways to attain the same in prior versions using NumberForm.

POSTED BY: Daniel Lichtblau
Answer
1 month ago

Group Abstract Group Abstract