Converting Decimals to Hex
Converting Hex to Binary is quite easy.
You just need paper and a pen.
But sometimes you have a sequence of decimal numbers, and you want to calculate their hexadecimal values.
bc
command is your magic tool.
The bc
command in Linux is a command-line utility that stands for “basic calculator”.
It provides a simple way to perform mathematical calculations within the terminal.
Here’s an example of how to use bc
command for simple mathematic calculation:
We can use the bc
command to convert decimal numbers to their hexadecimal equivalent.
For example, we can use bc
to obtain the hexadecimal values for: [170 187 204 221 238 255]
:
You can play with the obase
and ibase
options. For instance you can convert hexadecimals to decimals like this:
If you want more fun, try this command by yourself: