Reputation: 35
I need to convert the follow 4 byte integer to signed integer, like:
input 65535 value -1 input 65534 value -2 input 65533 value -3 and so on...
I tried the follow:
puts (65533).to_s(16) #=> fffd
puts (65533).to_s(16).unpack('s') #=> doesn't work properly... return 26214
Can someone help me with code above? Best Regards
Upvotes: 2
Views: 440