[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Spock@SAMSON.CADR.DIALNET.SYMBOLICS.COM: Floating-point round-off problems.]



    Date: Thu, 10 Aug 89 13:40:52 CDT
    From: mac%cadillac.cad.mcc.com@mcc.com (Mac Michaels)

    +>  Date: Thu, 10 Aug 89 08:00 PDT
    +>  From: Spock@SAMSON.CADR.DIALNET.SYMBOLICS.COM (Mr. Spock)
    +>  
    +>  Does anyone have a hack to correct for the losing floating-point math on
    +>  these Symbolics machines?
    +>  
    +>  Consider:
    +>  
    +>      (- 6 5.9) returns -> 0.099999905 instead of 0.1
    +>  
    +>  Thanks,
    +>  --Mark Alexander

    It looks like a problem common to more than Symbolics.  

    Austin Kyoto Common Lisp on a Sun 4-110 returns:

    0.09999999999999964

    Extension Language Kit (a superset of Scheme) on a Sun 3 returns:

    0.0999999999999996


    USPS: Mac Michaels,   3500 W.Balcones Center Dr.,   Austin,TX 78759
    ARPA: mac@mcc.com
    UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!mac 

Oh my GOD!  Look what happens with Sun's C:
Float:   0.099999904632568; 
double:  0.09999999999999964472863211995; 
immediate:  0.09999999999999964472863211995

It must be a conspiracy! Who's stealing our floating points!!??

Here's the source, see if you can figure it out!
#include <stdio.h>
main()

{ float a,b;
  double c,d;

  a = 6.0;
  c = 6.0;
  d = 5.9;
  b = 5.9;
  a = a - b;
  c = c - d;
 
  printf ( "\n\nFloat: %19.14g; double: %32.29g; immediate: %32.29g\n\n",
a ,  c, 
		(6.0 - 5.9));
  }