How can I convert numbers from one base to another?

How can I convert numbers from one base to another? Added: 05/03/02


You can use adb(1) to convert decimal to hexadecimal and hexadecimal to
decimal as follows:

To convert decimal 127 to hex:

$ echo '0d127=X' | adb

You should receive the following output:

7F

To convert hex 7F to decimal:

$ echo '0x7f=D' | adb

You should receive the following output:

127

Alternatively, the 'typeset' and 'set' shell builtins can be used to do
base conversions. See sh-posix(1) or ksh(1).



Home
FAQ