1833772 Members
2419 Online
110063 Solutions
New Discussion

HEX

 
Nobody's Hero
Valued Contributor

HEX

Is there a UNIX commonsd that can convert hex to decimal? I need it bad, I can't remember and I have no calculator. Im a baby boomer. Wnt through school with a calc.
UNIX IS GOOD
7 REPLIES 7
Bill McNAMARA_1
Honored Contributor

Re: HEX

Bill McNAMARA_1
Honored Contributor

Re: HEX

Rita C Workman
Honored Contributor

Re: HEX

Hi Robert,

And just so you have options (and a calculator)...

If you have a workstation with CDE..take a look at the toolbar. On the right side the icon in the middle (looks like a box with a ruler & calculator in it) is the Applications Manager. Click on this and then on Desktop Apps and you'll see a calculator. It's what I often use to convert hex/dec.

Rgrds,
Rita
Krishna Prasad
Trusted Contributor

Re: HEX

Try xd and od.

I think what you want is xd -s filename.

If this doesn't work try the man pages for xd an od.
Positive Results requires Positive Thinking
Jdamian
Respected Contributor

Re: HEX

You can use printf command or bc command.
In the next both examples the 250 number is printed:

printf "%d\n" 0xfA
echo "ibase=16; "FA | bc

notices:
1. printf command needs the hex value preceeded by 0x prefix.

2. printf is not case sensitive.

3. Instead printf, bc is case sensitive for hex values. Look the uppercase letters in second example.
Darrell Allen
Honored Contributor

Re: HEX

Hi Robert,

Windows PCs have a calculator that has a scientific view which lets you input a number in hex then click decimal to convert it.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
someone_4
Honored Contributor

Re: HEX

Hi Robert
Try this

To convert from decimal to hex (we are setting the output base 16, leaving input at 10):

$ bc -l
obase=16
256*1024*1024
10000000
255
FF
quit

To convert hex numbers to decimal (we are setting the input base to base 16, leaving the output base at 10)

$ bc -l
ibase=16
FF
255
40000000
1073741824
FFFF
65535
quit

Here is my orininal post when I had the same q.

http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x6b743fd7f72ad611abd50090277a778c,00.html


Richard