Hmmm, and then I could use struct to swing it back... so, I'll be
using string slices to model bitshifting then.

Always found it quite strange that working mathematically with binary
is so hard in programming languages. Even in Scheme, which will
happily play with imaginary numbers.

Regards,

Liam

On 8/4/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Liam Clarke wrote:
> > Problem is; I can't bitshift on floats, so can't test. Can't bitshift
> > on floats in C either.  Does anyone know how I could work on a binary
> > representation of a float? Any language at all, I'm desperate...
>
> In C you can certainly get access to the binary representation of a
> float as bytes. My C is really rusty but something like
> float x = 1.3;
> char* p = &x;
>
> will give you a pointer to the binary representation of x. You can do
> something similar with the struct module in Python; struct.pack() will
> give you a byte string containing the representation of a float.
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to