Revision: 17450
Updated Code
at September 4, 2009 19:40 by AzizLight
Updated Code
def decimal_to_hex(x) x = x.to_i q = 1 r = [] while q > 0 q = x / 16 r << x % 16 x = q end i = 0 r.each do |n| r[i] = case n when 10 then r[i] = 'A' when 11 then r[i] = 'B' when 12 then r[i] = 'C' when 13 then r[i] = 'D' when 14 then r[i] = 'E' when 15 then r[i] = 'F' else n = n end i += 1 end r.reverse.join end number = gets.chomp p decimal_to_hex(number)
Revision: 17449
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 4, 2009 19:39 by AzizLight
Initial Code
Initial URL
Initial Description
Initial Title
Decimal to Hexadecimal Terminal Script
Initial Tags
textmate, ruby, terminal
Initial Language
Ruby