How do I convert a hex strign to its 32 bit signed int equivalent in ruby?
for example
a = "fb6d8cf1" #hex string
[a].pack('H*').unpack('l') #from the documentation it unpacks to its 32 bit signed int
It converts to
-242455045
But the actual answer is
-76706575
Could you point me to what I am doing wrong?
You could flip the bytes yourself to get around the endian and sign issues: