summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
l---------c1
-rwxr-xr-xd21
2 files changed, 14 insertions, 8 deletions
diff --git a/c b/c
new file mode 120000
index 0000000..c59d9b6
--- /dev/null
+++ b/c
@@ -0,0 +1 @@
+d \ No newline at end of file
diff --git a/d b/d
index cedcfc0..9e70c3d 100755
--- a/d
+++ b/d
@@ -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