Created
April 12, 2019 21:24
-
-
Save pauldotknopf/f73fac8eeb9b3767b135bd2a1d5b5687 to your computer and use it in GitHub Desktop.
Helps commands for converting between decimal/binary/hex formats.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dec-to-hex() { | |
echo "ibase=10;obase=16;$1" | bc | |
} | |
function dec-to-bin() { | |
echo "ibase=10;obase=2;$1" | bc | |
} | |
function hex-to-dec() { | |
echo "ibase=16;obase=A;$1" | bc | |
} | |
function hex-to-bin() { | |
echo "ibase=16;obase=2;$1" | bc | |
} | |
function bin-to-hex() { | |
echo "ibase=2;obase=10000;$1" | bc | |
} | |
function bin-to-dec() { | |
echo "ibase=2;obase=A;$1" | bc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment