- To: mathgroup at smc.vnet.net
- Subject: [mg37002] Rounding numbers
- From: "Dana DeLouis" <delouis at bellsouth.net>
- Date: Sun, 6 Oct 2002 05:32:40 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello. Could somebody please inform me how to Round numbers to a
certain Accuracy using Mathematica 4.2. This is not as easy as it
Every function that I have read Rounds the Display, and not the actual
For example, I am trying to round numbers to 5 digits to the right of
the decimal place. The programming environment VBA has a "Round"
function that does this (ROUND(1/7,5)), but Mathematica "Round" rounds to an
Integer, so that is no good.
Using "N" does not work for rounding a number, it only affects the
x = N[1./3 + 2./7, 5]
I wanted 5, but it prints with "PrintPrecission" of 6.
As you can see, x was not rounded to 5 digits internally.
It's even worse for exact numbers. Help talks about displaying Pi to 40
(I use 20 here). However, it does not mention the problem when it is
less than 16.
x = N[Pi, 4]
3.14159 (Note 6 digits and not 4 as asked)
However, it does not matter, as x was not rounded anyway.
An article mentioned using "NumberForm," but that only affects the
display, and not the number.
All the examples like NumberForm, ScientificForm, etc all affect the
"Printing" of the number, not the number itself.
Another option I thought of was
a = SetAccuracy[1/3, 5]
All I want is a=0.33333
Thank you for any insight.
$VersionNumber -> 4.2
= = = = = = = = = = = = = = = = =
Prev by Date:
RE: How much graphics RAM?
Next by Date:
Re: Re: Accuracy and Precision
Previous by thread:
Re: trouble with pattern matching & manipulating
Next by thread:
Re: Rounding numbers