in reply to Re^2: Float/double to hex?
in thread Float/double to hex?

I know a float is a four byte value. I want to have the hex string representation of those four bytes. If (2**16) is 65536, I want 65536 to be 0x0000ffff (or 0xffff0000, whatever order). Mike

Replies are listed 'Best First'.
Re^4: Float/double to hex?
by edwyr (Sexton) on Feb 19, 2013 at 22:03 UTC
    Here is what I am looking for (running inside "perl -d -e 1"): x 2**16 65536 x unpack('h*', pack('i', 65535)) 'ffff0000' $x = 1 / 7 x $x 0.142857142857143 x unpack('h*', pack('f', $x)) '529421e3'