[OT Ruby] Displaying a binary?

How to I display the binary equivalent of a number? I tried this:

b = 0b1101
puts b # returns decimal value ( 13 )

b.to_bn # generates “unable to convert FIXNUM to STRING…” error.

Larry K. wrote:

How to I display the binary equivalent of a number? I tried this:

b = 0b1101
puts b # returns decimal value ( 13 )

b.to_bn # generates “unable to convert FIXNUM to STRING…” error.

.to_s(base)

So, in this case

13.to_s(2)
=> “1101”

How to I display the binary equivalent of a number? I tried this:

b = 0b1101
puts b # returns decimal value ( 13 )

b.to_bn # generates “unable to convert FIXNUM to STRING…” error.

b.to_s(2)

Regards,
Rimantas

http://rimantas.com/

How elegant!, Wonderful!
Thanks,
-Larry