[フレーム]
Last Updated: February 25, 2016
·
585
· navateja

Convert a number into binary using ruby

def converttobinary(n)
 n.to_s(2).to_i
end

if you need all the digits of the binary representation in an array..

n.to_s(2).split("").map(&:to_i)

AltStyle によって変換されたページ (->オリジナル) /