Add bin/base

This commit is contained in:
Henrik Lissner 2017-04-25 03:16:53 -04:00
parent d16f0d14af
commit 6857049709

12
bin/base Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Converts a number from one base to another. DEST_RADIX is optional and
# defaults to 10.
#
# Usage: base [SRC_RADIX] [NUMBER] [DEST_RADIX]
# Examples:
# + base 2 110 #=> 6
# + base 2 110 10 #=> 6
# + base 16 FF #=> 6
bc <<< "obase=${3:-10};ibase=$1;$2"