Simple Q: bit string -> integer

Is there a simple way to induce a bit string into an
integer; for example, "10010000" into 144? And also,
to show a Fixnum in its different representations
(hex, num, binary)?

···

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Try this

str = "10010000"
p str.to_i(2)
puts
p 255.to_s(16)
p 255.to_s(2)

Harry

···

On 5/6/07, Todd Benson <toddkennethbenson@yahoo.com> wrote:

Is there a simple way to induce a bit string into an
integer; for example, "10010000" into 144? And also,
to show a Fixnum in its different representations
(hex, num, binary)?

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--

A Look into Japanese Ruby List in English

Todd Benson wrote:

Is there a simple way to induce a bit string into an
integer; for example, "10010000" into 144?

"10010000".to_i(2)

And also,
to show a Fixnum in its different representations
(hex, num, binary)?

144.to_s(16), 144.to_s(2)

But what's "num"?

···

--
Florian Frank

Yes, thanks a bunch. For some reason, #to_i was the
last place I thought to look.

Todd

···

--- Harry Kakueki <list.push@gmail.com> wrote:

Try this

str = "10010000"
p str.to_i(2)
puts
p 255.to_s(16)
p 255.to_s(2)

Harry

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

"num" as in my brain is "numb" from staring at 1's and 0's.

···

--- Florian Frank <flori@nixe.ping.de> wrote:

Todd Benson wrote:
> And also,
> to show a Fixnum in its different representations
> (hex, num, binary)?

144.to_s(16), 144.to_s(2)

But what's "num"?

--
Florian Frank

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around