Return to Snippet

Revision: 17443
at September 4, 2009 17:30 by AzizLight


Updated Code
def decimal_to_binar(x)
  z = []
  while x >= 1
    z << x % 2
    x /= 2
  end
  z.reverse.join(" ")
end

number = gets.chomp
puts "decimal : #{number}nbinary  : #{decimal_to_binar(number.to_i)}"

Revision: 17442
at September 4, 2009 17:30 by AzizLight


Initial Code
def decimal_to_binar(x)
  z = []
  while x >= 1
    z << x % 2
    x /= 2
  end
  z.reverse.join(" ")
end

number = gets.chomp
puts "decimal : #{number}nbinary  : #{decimal_to_binar(number.to_i)}"

Initial URL


Initial Description


Initial Title
Decimal to Binary Terminal Script

Initial Tags
textmate, ruby, terminal

Initial Language
Ruby