Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A simple bash shell hex converter' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A simple bash shell hex converter
Authored by: Kibe on Sep 01, '03 04:00:02PM

Well, i just found a way that is simple enough to actually remember. Type in "bc" w/o the quotes, then return in the default shell(i dont know about ne others) then change the variables "ibase" and "obase" to suit ur input and output respectivly. I.e:

[------:~] --------% bc
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
obase = 16
300
12C

that is how i converted 300 into hex, to go back i wud now type this:
ibase = 16
obase = 10
12C
300

this works for any numbering system. input limits are base 2-16, output is 2-999.
so if im feeling insane i can convert base 2(binary) into base 600.
type in "man bc" for more info including how base systems higher than 16 are displayed(11-16 use lettering like hex, base 16)

this is the easiest way by far to both use and remember, not to mention actually type corectly.



[ Reply to This | # ]