From: "Hal E. Fulton" Date: 2002-09-10T04:23:53+09:00 Subject: Re: Reading in Hex numbers. ----- Original Message ----- From: To: "ruby-talk ML" Sent: Monday, September 09, 2002 10:55 AM Subject: Re: Reading in Hex numbers. > > 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? > > For hex and octal you could use scanf > (http://www.rubyhacker.com/code/scanf), though the more general > solution of Integer might be better if you're also doing binary. > (Hmmm... binary in scanf... hmmm...) :) :) I *knew* you would pick up on that, David. I think adding binary to scanf is fine as long as we don't run out of alphabet. I.e., assuming %b is the logical choice and it doesn't already mean something that we're likely to implement in the future. Hal