MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: rounding off numbers

  • To: mathgroup at
  • Subject: [mg23945] RE: [mg23884] rounding off numbers
  • From: "David Park" <djmp at>
  • Date: Fri, 16 Jun 2000 00:57:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

> -----Original Message-----
> From: JikaiRF at [mailto:JikaiRF at]
To: mathgroup at
>     Dear members of MathGroup,
>     I would like to report a problem rounding off numbers with
> Mathematica.
> Take, for example, the number 81.3736.  Since I want to round it
> off to the
> second decimal, I use the formula 81.3736 + (9-4)*0.001.  And I obtain
> 81.3786.
> Then, if I round off the third decimal point of the above result,
> 81.3786, I
> can obtain the required answer 81.37.
>     In order to establish the above procedure on Mathematica, I tried the
> program:
>     N[81.3736 +(9-4)*0.001, 4]
>     However, the result was 81.38, because the function of N is, in this
> situation, designed to
> round
> the third decimal of 81.3786, that is,8.
>     I need to round off the third decimal in the above program.
>     I would like to know how to program Mathematica to achieve this.
>     I hope to receive useful advice from you, as I have done previously.
>         Sincerely,
>         Fujio Takata


The purpose of N is to convert exact numerical expressions into approximate
expressions. In earlier versions it could be used to format output, but no
longer. So it should not be used to format output, nor to set the precision
or accuracy of a number, unless you are converting an exact number to an
extended precision approximate number.

If all you want to do is format the output, without actually changing the
number use this:

NumberForm[81.3736, {4, 2}]

On the other hand, if you wish to actually change the precision of the
number you can use this:


Or this:

SetAccuracy[81.3736, 2]

See Section 3.1 in The Mathematica Book.

David Park
djmp at

  • Prev by Date: Re: Monte Carlo in Mathematica ?
  • Next by Date: Gradient in FindMinimum
  • Previous by thread: rounding off numbers
  • Next by thread: Re: rounding off numbers