Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*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 2001

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

Search the Archive

Re: output precision

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26569] Re: [mg26553] output precision
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Fri, 5 Jan 2001 22:23:04 -0500 (EST)
  • References: <200101050534.AAA20726@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In[1]:=
39.78 9.37
Out[1]=
372.739

Use NumberForm to display the result to the desired precision:

In[2]:=
Table[NumberForm[39.78 9.37, j], {j, 5, 8}]
Out[2]=
{"372.74", "372.739", "372.7386", "372.7386"}

Both your factors in this example are machine-precision numbers, so that
they are handled by the double-precision floating point hardware of your
machine as approximate real numbers, and hence the actual result (i.e., what
Mathematica stores internally) is also an approximate number:

In[3]:=
InputForm[%]
Out[3]//InputForm=
372.73859999999996

So you must bear in mind the distinction between the result of an arithmetic
operation (what Mathematica actually stores) and what is shown on your
display, and this you can control with NumberForm.

Tomas Garza
Mexico City




----- Original Message -----
From: "Peter Klamser" <klamser at t-online.de>
To: mathgroup at smc.vnet.net
Subject: [mg26569] [mg26553] output precision


> Hi, a trivial problem:
>
> 39.78 9.37=372.7386
>
> Mathematica says:
>
> 39.78 9.37=372.739
>
> How can I make Mathematica output the prescise result?
>
> Regrads, peter Klamser
>
>
>
>



  • Prev by Date: Re: mathematica log sessions
  • Next by Date: Re: Dirichlet generating function
  • Previous by thread: Re: output precision
  • Next by thread: Re: output precision