[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Bob Sanders

5/30/2008 10:55:00 AM

I can't find a clue how to convert a hexadecimal number to a binary
number. Anyone know?
--
Posted via http://www.ruby-....

5 Answers

Oscar Del Ben

5/30/2008 11:03:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

number.to_s(2)

2008/5/30, Bob Sanders <small.business.strategy@gmail.com>:
>
> I can't find a clue how to convert a hexadecimal number to a binary
> number. Anyone know?
>
> --
> Posted via http://www.ruby-....
>
>

Bill Kelly

5/30/2008 11:05:00 AM

0


From: "Bob Sanders" <small.business.strategy@gmail.com>
>
>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



Ryan Lewis

5/30/2008 11:35:00 AM

0

Bob Sanders wrote:
> I can't find a clue how to convert a hexadecimal number to a binary
> number. Anyone know?

From http://www.tek-tips.com/viewthread.cfm?qid=1026407&...
> 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.
--
Posted via http://www.ruby-....

Bob Sanders

5/30/2008 11:45:00 AM

0

Ryan Lewis wrote:
> Bob Sanders wrote:
>> I can't find a clue how to convert a hexadecimal number to a binary
>> number. Anyone know?
>
> From http://www.tek-tips.com/viewthread.cfm?qid=1026407&...
> > 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!
--
Posted via http://www.ruby-....

Ryan Lewis

5/30/2008 11:50:00 AM

0

Bob Sanders wrote:
> Big thanks for the quick reply, Ryan!

NP, I just happened to needed this same info like two days ago
--
Posted via http://www.ruby-....