diff options
author | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-10-18 11:52:41 +0100 |
---|---|---|
committer | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-10-18 11:52:41 +0100 |
commit | 5a2fb234cf6c750518bd265256af3e956ffc2193 (patch) | |
tree | 8a02123bf0a4438e93c9e7874a8c75d4456b7294 /d | |
parent | 0c8741059abcaaed99e627e42b99c50a17abbf08 (diff) |
Added ascii char to d, and c link
Diffstat (limited to 'd')
-rwxr-xr-x | d | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -12,22 +12,27 @@ when 'o' num = num.to_i(8) when 'b' num = num.to_i(2) +when 'c' + num = num.ord end -dec = hex = oct = bin = true +dec = hex = oct = bin = char = true out = ARGV.shift case out when 'd' - hex = oct = bin = false + hex = oct = bin = char = false when 'h' - dec = oct = bin = false + dec = oct = bin = char = false when 'o' - dec = hex = bin = false + dec = hex = bin = char = false when 'b' - dec = hex = oct = false + dec = hex = oct = char = false +when 'c' + dec = hex = oct = bin = false end puts " Decimal : #{num.to_s(10)}" if dec -puts "Hexadecimal : #{num.to_s(16)}" if hex -puts " Octal : #{num.to_s(8)}" if oct -puts " Binary : #{num.to_s(2)}" if bin +puts "Hexadecimal : 0x#{num.to_s(16)}" if hex +puts " Octal : 0#{num.to_s(8)}" if oct +puts " Binary : 0b#{num.to_s(2)}" if bin +puts " ASCII : '#{num.chr}'" if char |