Two-cent Tip: number conversion between between base-x to base-y
Mulyadi Santosa [mulyadi.santosa at gmail.com]
Sat, 18 Jul 2009 20:35:59 +0700
For those who needs quick help on number conversion between base-x to base-y, bc can lend a help here. For example, what's the hexadecimal form of 116?:
$ echo 'obase=16; 116' | bc 74
And what does binary 11010101 look in decimal?
$ echo 'ibase=2; 11010101' | bc 213
By doing below step, you directly convert binary 11010101 to hexadecimal:
$ echo 'obase=16; ibase=2; 11010101' | bc D5
Note that "obase" must preced "ibase" in order to make a correct final result.
-- Mulyadi Santosa Freelance Linux trainer blog: the-hydra.blogspot.com