Base conversion

From s23
Jump to navigation Jump to search
#/bin/bash
echo "23 decimal is `echo 'obase=16; ibase=10; 23' | bc` in hex."
23 decimal is 17 in hex.
echo "23 in hex is `echo 'obase=10; ibase=16; 23' | bc` in decimal."
23 in hex is 35 in decimal.
echo "666 in octal is `echo 'obase=10; ibase=8; 666' | bc` in decimal."
666 in octal is 438 in decimal.
echo "77 base 7 is `echo 'obase=10; ibase=7; 77' | bc` in decimal."
77 base 7 is 48 in decimal.
echo "10111 binary is `echo 'obase=10; ibase=2; 10111' | bc` in decimal."
10111 binary is 23 in decimal.
echo "There are only `echo 'obase=10; ibase=2; 10' | bc` types of people ..."
There are only 2 types of people .. [1]

etc ...