Re: MachinePrecission and FPU
- To: mathgroup at smc.vnet.net
- Subject: [mg81292] Re: MachinePrecission and FPU
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 18 Sep 2007 05:55:15 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fcnl4n$s65$1@smc.vnet.net>
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,
--
Jean-Marc