Programming-Idioms

History of Idiom 76 > diff from v24 to v25

Edit summary for version 25 :

Version 24

2015-09-03, 15:04:53

Version 25

2015-09-03, 15:45:24

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
base = 2
s = x.to_s(base)
Doc URL
http://ruby-doc.org/core-2.2.3/Fixnum.html#method-i-to_s