From: Gary Wright Date: 2008-01-10T05:29:57+09:00 Subject: Re: Question about Hex => Signed Int On Jan 9, 2008, at 2:48 PM, Tim Conner wrote: > Hello, > Is there a ruby function to convert the following hexadecimal numbers > into the corresponding signed integers or will i need to write > something > to do the conversion? Sorry if this question is stupid but i'm pretty > new to all this. > > 0xFF467A7B => -12158341 > 0x38CFEF => 3723247 The tricky part is dealing with the twos compliment notation but String#to_i will do the hex/decimal conversion: >> "0xFF467A7B".to_i(16) - 0x100000000 => -12158341 >> "0x38CFEF".to_i(16) => 3723247 Gary Wright