MathGroup Archive 2007

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

Search the Archive

Re: MachinePrecission and FPU

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81294] Re: MachinePrecission and FPU
  • From: Daniel Huber <dh at metrohm.ch>
  • Date: Tue, 18 Sep 2007 05:56:48 -0400 (EDT)
  • References: <fcnl4n$s65$1@smc.vnet.net> <46EF98F4.8060601@gmail.com>

Hy Jean-Marc,
thank's for the response. Note that 0.03/0.006 gives you a rounded 
number (OutputForm). If you want to see all digits you have to look at 
the InputForm:
0.03/0.006 //InputForm
it would be interessting to know if with this you may get a different 
result.
Daniel

Jean-Marc Gulliet wrote:
> dh wrote:
>
>> I could trace down a discrepancy between a C program and Mathematica 
>> to the
>>
>> following. Try to compute 0.03/0.006 and you get 4.9999999.. as neither
>>
>> 0.03 nor 0.006 can be represented accurately, this is not amazing.
>
> On my system (Intel Pentium 4 HT 2.6 MHz), I get consistently 5.0 with 
> version 6.0.1 and 5.2.
>
> In[1]:= 0.03/0.006
>
> Out[1]= 5.
>
> In[2]:= $Version
>
> Out[2]= "6.0 for Microsoft Windows (32-bit) (June 19, 2007)"
>
> In[1]:=
> 0.03/0.006
>
> Out[1]=
> 5.
>
> In[2]:=
> $Version
>
> Out[2]=
> 5.2 for Microsoft Windows (June 20, 2005)
>
>> However, the same calculated with C and C++ on PC's gives 5.0000..
>
> /* Very crude C program */
>
> #include <stdio.h>
>
> int main(void)
> {
>     printf("The value of 0.03/0.006 is %f\n", 0.03/0.006);
>
>     return 0;
> }
>
> which returns after compilation
>
> The value of 0.03/0.006 is 5.000000
>
>> Now, WHY?
>
> Could that be hardware dependent? You did not mention either the 
> version of Mathematica your used or the cpu.
>
> <snip>
>
> Regards,

-- 

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.ch>



  • Prev by Date: Re: How to set working directory?
  • Next by Date: Re: Can an arrow be drawn on a 3D plot?
  • Previous by thread: Re: MachinePrecission and FPU
  • Next by thread: Re: MachinePrecission and FPU