MathGroup Archive 2013

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

Search the Archive

Re: Precision

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129343] Re: Precision
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 7 Jan 2013 00:35:14 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

On 1/5/13 at 2:19 AM, tio540s1 at gmail.com (Rob Ryan) wrote:

>My frustration is growing. I simply want to add (for example):
>103971.66+52282.64+2998.27. These are dollars and cents and I'd like
>to keep the cents. But when I input that line, I get 159923. When I
>input: N[(103971.66+52282.64+2998.27),20] I STILL get 159923. What
>do I do to get 159952.57? I've used "SetPrecision", etc. with still
>no result. I note that when I type 103971.66 and hit shift-return,
>the output is 103972. If I then type "InputForm[%]" I get 103971.66.

>There simply has to be an easy way to add these numbers - any
>calculator watch can do it!

Mathematica is adding the numbers correctly. But by default,
Mathematica *displays* only 6 digits.

SetPrecision, N etc. impact the precision of the value
Mathematica uses but have no effect on the display of the result.

You can either explicitly tell Mathematica to display the result
as you want or set your preferences so that all results display
the way you want.

Here is one way to explicitly tell Mathematica to display the 2
digits after the decimal point with 6 digits to the left of the
decimal point

In[4]:= x = 103971.66 + 52282.64 + 2998.27

Out[4]= 159253.

In[5]:= NumberForm[x, {9, 2}]

Out[5]//NumberForm= 159252.57

If you want to change your default display settings click on the
Appearance tab in preferences then the Formatting tab and change
the settings as you prefer.




  • Prev by Date: Re: Attaching a notebook to a message
  • Next by Date: Re: PolynomialQuotient slow
  • Previous by thread: Re: Precision
  • Next by thread: Re: Precision