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