C Floating point arithmetic
jimc at ucla-cs.UUCP
jimc at ucla-cs.UUCP
Tue Dec 10 08:27:34 AEST 1985
In article <4647 at alice.UUCP> ark at 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 at locus.UCLA.EDU
More information about the Comp.lang.c
mailing list