On 2002.09.19, akolarik / sonexis.com <akolarik / sonexis.com> wrote: > > There's probably a better way, but: > > > > [0xFFFFFFC4].pack("l").unpack("l")[0] # => -60 > > > > -- Dossy > > I definitely wouldn't have stumbled on that for a while ;-) > Guess I'll have to check the doc to figure out what's going on there, but in > the meantime it works! > Thanks a lot, The pack takes a Fixnum and converts it to a String of 4 bytes which represents the value ("l" means long). Then, we unpack the 4 bytes as a signed long back into a Fixnum. "L" would be unsigned. #pack and #unpack are incredibly powerful. -- Dossy -- Dossy Shiobara mail: dossy / panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)