Fun with numbers - dammit, but I want a cast!
Carl Banks
imbosol at aerojockey.com
Mon Aug 11 20:57:02 EDT 2003
Erik Max Francis wrote:
> Carl Banks wrote:
>
>> Certainly not. Most type casts actually change bits.
>
> Some casts do. Some merely invoke conversions.
>
>> For example,
>> supposing floats and longs are both 32 bits, the expression (float)1L
>> will *not* return the floating point number with the same bit pattern
>> as 1L. It returns 1.0.
>
> But the C++ equivalent, something like (float) 1, would _not_ return the
> floating point number with the same bit pattern as 1L either. It would
> simply invoke the conversion from int to float. What you're talking
> about would be something like *(float *) &i.
It seems you didn't read what I wrote carefully. I was talking about
C, not C++. Neither I nor the post I replied to mentioned C++ once.
I mentioned the C standard several times, never the C++ standard.
Type casts in C are as I described.
--
CARL BANKS
"You don't run Microsoft Windows. Microsoft Windows runs you."
More information about the Python-list
mailing list