From: Mike Stok Date: 2002-09-09T22:51:18+09:00 Subject: Re: Reading in Hex numbers. In article <9ba6a8da.0209090511.35a87842@posting.google.com>, Khurram wrote: > Hi all, > > I want to read in a file that has hex numbers, which are stored with > the "0x" hex prefix (i.e. 0x12345678). Is there a built in function > that will do the conversion, similiar to "to_i", for hex numbers? > > Also... is there something also for binary? Octal? You can use Integer on a string e.g. irb(main):001:0> Integer('0xE84C') 59468 irb(main):002:0> Integer('040') 32 irb(main):003:0> Integer('0b1011') 11 Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA