Hex & Decimal 

Hex to character 

Newsgroups: comp.unix.shell
Date: 1995/09/14
|> I want to convert a hex number to the character value. In C I can do the following
|>
|>
|>    printf("%c\n", 0x21);

You can use the desk calculator /bin/dc:

Num=21
echo "16i${Num}P" | dc

Explaination of commands:

dc uses postfix (reverse Polish) notation. The command string is interpreted as:

  1. "16" - Pushes 16 on stack
  2. "i" - Pops top of stack and uses this value to set the input base. Thus, all further inputs are hex.
  3. "21" - Push 21 on stack. Interpreted as hex value.
  4. "P" - Pop top of stack, interpret as a char, and print it.

Praveen Puri

Hex to Decimal in "standard" Unix - How ? 

Newsgroups: comp.unix.questions
Date: 1995/11/16
|> Is there any tools in unix that can do HEX --> Decimal (and the
|> reverse) conversions...
dec to hex
lucio 291 > bc
ibase=10
obase=16
10
A             <-- indicates computer reply
11
B             <--
16
10            <--
ctl-D
hex to dec
lucio 295 > bc
ibase=16              do NOT specify obase !!
0A
10            <--
0B
11            <--
10
16            <--
FF
255           <--

Lucio Chiappetti

Hex to Decimal in "standard" Unix - How ? 

$ bc
ibase=16
0A
10
0a
(standard_in) 3: parse error