[Tutor] Binary fractions, recommendations?

Kent Johnson kent37 at tds.net
Fri Aug 4 12:58:06 CEST 2006

Alan Gauld wrote:
> Does anyone know how I could work on a binary
>> representation of a float? Any language at all,
>>> 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;
> That doesn't give you a binary representation of the
> number just access to the bytes of the IEEE representation.
> bit shifting that would be pretty pointless IMHO.
I guess it depends on what the OP means by "binary representation of a 
float". The request is ambiguous. I interpret it as, access to the 
actual bits of the representation, which the above code will give. 
Another interpretation is, an ASCII representation of the bits of the 
number, which seems to be what you mean.


More information about the Tutor mailing list