Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!ucla-cs!jimc From: jimc@ucla-cs.UUCP Newsgroups: net.lang.c Subject: Re: C Floating point arithmetic Message-ID: <7933@ucla-cs.ARPA> Date: Mon, 9-Dec-85 17:27:34 EST Article-I.D.: ucla-cs.7933 Posted: Mon Dec 9 17:27:34 1985 Date-Received: Wed, 11-Dec-85 22:06:40 EST References: <1087@lll-crg.ARpA> <4647@alice.UUCP> Reply-To: jimc@ucla-cs.UUCP (Jim Carter) Organization: UCLA Computer Science Department Lines: 17 In article <4647@alice.UUCP> ark@alice.UucP (Andrew Koenig) writes: >> float a,b; >> a = b + 1.0; /* Gets done in double because 1.0 is a double. >> Gag me with a spoon. */ > >Nah, gets done in single because the compiler realizes that 1.0 has >the same representation in single and double, and therefore that >the result of the addition will be the same. Don't forget the IEEE float standard (e.g. 8087 chip), where a float has an 8-bit exponent and a double has 11 bits. The compiler has to recognize that 1.0D0 .eq. 1.0E0 (pardon my Fortran) even though the bit patterns differ. This is certainly feasible, but takes more smarts. Gag me with a spoon. James F. Carter (213) 206-1306 UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024 UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc ARPA:jimc@locus.UCLA.EDU