Converting from one numeral system to another can be done using the
bc command.
Here are a few examples in the form of functions:
# -------------------------------------------------------------------------- #
# - Decimal to ....
# -------------------------------------------------------------------------- #
PHP Code:
# Convert decimal to binary
function decToBin() {
echo "obase=2;$1" | bc
}
Code:
$ decToBin 19
10011
...