Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: rounding off numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23922] Re: rounding off numbers
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 16 Jun 2000 00:57:01 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <8i9p6u$2et@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In Mathematica 4.0, Windows version, the result is:

    N[81.3736 + (9 - 4)*0.001, 4]
81.3786

How about the following:

   x = 81.3736; n = 2;
   10.^(-n) Round[10^n x] 
81.37

Or:

  N[10^(-2) Round[10^2 x]]
81.37

However, your question raises the issue of why you would want to round
numbers during computation.  If all you really need is to round the
final result of a computation, then this becomes a matter of display. 
So you could use, for example:

  NumberForm[x, 4]
"81.37"           

(The actual result shown in the notebook is a NumberForm output cell
with a label such as "Out[nn]//NumberForm="  instead of the usual
"Out[nn]= ", and the quotes are NOT shown around the number 81.37.)
JikaiRF at aol.com wrote:
> 
>     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
> 
>     P.S. My e-mail address is:  JikaiRF at aol.com
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       phone 413 549-1020 (H)
Univ. of Massachusetts                     413 545-2859 (W)
Amherst, MA 01003-4515


  • Prev by Date: RE: Problem with implementing the following functions
  • Next by Date: RE: Sums and Products: Compact Notation and Differentiation
  • Previous by thread: RE: rounding off numbers
  • Next by thread: Re: Linking with C++