Fun with numbers - dammit, but I want a cast!

Erik Max Francis max at alcyone.com
Tue Aug 12 02:36:15 CEST 2003


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.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Life is an effort that deserves a better cause.
\__/  Karl Kraus




More information about the Python-list mailing list