Date: Sat, 19 Nov 1994 04:46:56 -0500 From: davis AT amy DOT tch DOT harvard DOT edu ("John E. Davis") To: dolan AT fnoc DOT navy DOT mil, gordon AT spot DOT colorado DOT edu Subject: Re: printf or floating point error????? Cc: djgpp AT sun DOT soe DOT clarkson DOT edu >A cast does not say "convert this value on the right to this type and >assign it to the recipient on the left", a cast says "for right now, >the bit pattern contained in the piece of _storage_ at the location >indicated by the object being cast IS this type, use it as this type >and pass the appropriate value under that interpretation into the >recipient on the left", not at all the same thing, it turns out. I do not think that this statement is correct. Consider: float x, y; long i = 10; /* assume sizeof (float) == sizeof (long) */ x = (float) i; y = *(float *) &i; Here `x' will have the value of 10.0 whereas `y' has the bit pattern that you are suggesting above. `y' will will almost certainly not be 10.0 and `x' will not have the bit pattern of `i'. That is, the float cast above will definitely modify the bit pattern of i. --John