Mail Archives: djgpp/1994/11/19/06:48:25
>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
- Raw text -