Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (10) AWS (5) numerology (5)

Monday, July 6, 2015

Decimal to Hexadecimal conversion through bc command - HPUX


Binary = base is 2

Hexadecimal = base is 16

By default we use decimal value.


1. Convert Decimal to Hexadecimal through bc command :

Here we have to define obase value obase - output base; here obase=16 since we are converting the decimal values to Hexadecimal

testserver:/] bc
obase=16
198
C6

or

testserver:/] echo "obase=16; 198" |bc
C6



2. Convert Hexadecimal to Decimal through bc command:

Here we have to define ibase value ibase - input base; here ibase=16 since we are converting Hexadecimal values to the decimal values.


testserver:/] bc
ibase=16
C6
198

or

testserver:/] echo "ibase=16; C6" |bc
198


Similarly we can convert decimal to oct or decimal to Bin or decimal to any base number and vice versa.


Thanks...
Kiran Jadhav


**Let's Share knowledge and keep visiting here**

No comments:

Post a Comment