MathGroup Archive 2007

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

Search the Archive

Re: MachinePrecission and FPU

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81314] Re: MachinePrecission and FPU
  • From: "marks at wolfram.com" <marks at wolfram.com>
  • Date: Wed, 19 Sep 2007 05:23:11 -0400 (EDT)
  • References: <fcnl4n$s65$1@smc.vnet.net><46EF98F4.8060601@gmail.com>

There is currently no way to set the rounding mode at run-time.
However this is not the cause of the issue at hand.

The reason for the difference is that a/b does not parse
to divide but rather multiplication by a reciprocal.

In[1]:= FullForm[a/b]

Out[1]//FullForm= Times[a, Power[b, -1]]

Therefore there are two potential rounding errors here,
one in reciprocation of 0.006 and one in the subsequent
multiplication by 0.03.

In[2]:= InputForm[0.03/0.006]

Out[2]//InputForm= 4.999999999999999

If this difference is important, it id possible to directly
access floating point division by calling Divide:

In[3]:= InputForm[Divide[0.03, 0.006]]

Out[3]//InputForm= 5.

Note that other differences between Mathematica and
a C/C++ program may easily occur. These might
arise from a different order of floating point operations
or architectural subtleties - for example an optimizing
compiler's use of Intel's extended (80 bit) double
arithmetic being used instead of IEEE 64 bit double
precision.

Mark Sofroniou,
Wolfram Research



  • Prev by Date: How to slow down SWF?
  • Next by Date: Re: Aspect Ratio question
  • Previous by thread: Re: MachinePrecission and FPU
  • Next by thread: Re: MachinePrecission and FPU