helm/bin/base

13 lines
292 B
Plaintext
Raw Normal View History

2017-04-25 00:16:53 -07:00
#!/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"