Re: MachinePrecission and FPU
- To: mathgroup at smc.vnet.net
- Subject: [mg81316] Re: MachinePrecission and FPU
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Wed, 19 Sep 2007 05:24:31 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fcnl4n$s65$1@smc.vnet.net> <46EF98F4.8060601@gmail.com> <fco7i4$3sq$1@smc.vnet.net>
Daniel Huber wrote: > 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 I confirm that with ImputForm I get 4.9999... (I did not try the first time). > 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, >