On Dec 6, 9:35 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Dec 6, 8:17 pm, Steven D'Aprano <[EMAIL PROTECTED]
> > I don't like "cast", because a cast is an instruction to the compiler to
> > treat data as some type other than what it was defined as.
> It doesn't
> > create a new piece of data. (At least in C-like languages.)
>
> Actually, C-like languages do exactly that.  (float)i doesn't take the
> bits of int i and treat them as if they were a float, it creates new
> data in the appropriate data type that matches the value of i
> semantically, which would have a very different bit pattern.

'(float&) i' does what he said.

        int i;
        float& f= ( (float&) i );
        f= 1;
        printf( "%x %f\n", i, f );

/Output:

3f800000 1.000000

Sorry for the tangent.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to