# How do you convert a hexadecimal number to a binary number?

I can’t find a clue how to convert a hexadecimal number to a binary
number. Anyone know?

Bob S. wrote:

I can’t find a clue how to convert a hexadecimal number to a binary
number. Anyone know?

You have to convert items using methods such as String#to_i(base=10)
and Fixnum#to_s(base=10). These would be for decimal values. Change
to (base=16) for hexadecimal values, (base=2) for binary values,
etc.

Ryan L. wrote:

Bob S. wrote:

I can’t find a clue how to convert a hexadecimal number to a binary
number. Anyone know?

You have to convert items using methods such as String#to_i(base=10)
and Fixnum#to_s(base=10). These would be for decimal values. Change
to (base=16) for hexadecimal values, (base=2) for binary values,
etc.

Big thanks for the quick reply, Ryan!

Bob S. wrote:

Big thanks for the quick reply, Ryan!

NP, I just happened to needed this same info like two days ago

From: “Bob S.” [email protected]

I can’t find a clue how to convert a hexadecimal number to a binary
number. Anyone know?

“beef”.to_i(16).to_s(2)
=> “1011111011101111”

Regards,

Bill

number.to_s(2)

2008/5/30, Bob S. [email protected]: