Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!super!udel!rochester!rutgers!apple!bionet!agate!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: C question Message-ID: <8810112106.AA14840@cory.Berkeley.EDU> Date: 11 Oct 88 21:06:22 GMT Article-I.D.: cory.8810112106.AA14840 Sender: daemon@ucbvax.BERKELEY.EDU Lines: 26 :I have stumbled onto one of those C mystery problems, using Lattice 4.01. : :INT_MAX is a #define for the largest int. In my code I have : : r1 = 1.0/(double)INT_MAX : :and : : double im = INT_MAX; : r2 = 1.0/im; : :Guess what? r1 and r2 get different values. How come? : : .. only FFP The reason is that the first line, 1.0/(double)INT_MAX is a constant expression which is evaluated at compile time, using the maximum precision available to the compiler. The second line is evaluated run-time by the FFP library. Since the FFP representation of the maximum-sized integer looses some accuracy (you cannot represent a 32 bit-sized non-power-of-2 integer with a 32 bit FFP quantity without some error), the evaluation comes out slightly flawed. -Matt