I want to do some text analysis of stock data. I cannot do what I want using numbers, only alpha or hex. I want to convert the numbers to the four byte hex representation of a float (or eight bytes for a double).
I didn't think to check CPAN. I'll try the above code.
Thanks to all that replied.
Mike
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
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'