convert floats to their 4 byte representation

godavemon davefowler at gmail.com
Wed Jun 14 10:58:13 EDT 2006


I need to take floats and dump out their 4 byte hex representation.
This is easy with ints with the built in hex function or even better
for my purpose

def hex( number, size ):
	s = "%"+str(size) + "X"
	return (s % number).replace(' ', '0')

but I haven't been able to find anything for floats.  Any help would be
great.




More information about the Python-list mailing list