[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: how to translate base 10 number into base 2 number

Li Chen

1/14/2007 5:19:00 PM


> This doesn't answer your question, but in case you
> were not aware, Ruby
> will do this conversion for you:
>
>
> a = 125
> puts a.to_s(2)
> 1111101
>
>
> Kirk Haines

Thanks. But is is possible do the opposite, from
111101 to 125 change?

Li



____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/short...

2 Answers

Jeremy Tregunna

1/14/2007 5:21:00 PM

0


On 14-Jan-07, at 12:19 PM, chen li wrote:

>
>> This doesn't answer your question, but in case you
>> were not aware, Ruby
>> will do this conversion for you:
>>
>>
>> a = 125
>> puts a.to_s(2)
>> 1111101
>>
>>
>> Kirk Haines
>
> Thanks. But is is possible do the opposite, from
> 111101 to 125 change?

"111101".to_i(2)
=> 125

--
Jeremy Tregunna
jtregunna@blurgle.ca

khaines

1/14/2007 5:54:00 PM

0