Caffeinated Bitstream
Lowercase hexadecimal hack for GNU bc
I frequently use the command-line GNU bc calculator to do quick arithmetic while debugging C programs. An ongoing annoyance is bc's insistence that the hexadecimal digits A-F must be entered in uppercase. Other software, such as GDB and printf("%p",...), output lowercase hexadecimal digits, which keeps me from cutting and pasting the values into bc. Manually typing the values can be a big time sink when I need to perform a lot of calculations.
I finally got fed up with this behavior and made a version of bc with the following modifications:
- Hexadecimal digits may now be entered in lowercase.
- Input and output defaults to base 16.
Here are links to the baseline bc source code, and the patch with my modifications:
- bc-1.06.tar.gz (via prep.ai.mit.edu)
- bc-lowercase-hex-hack.patch
tar xvfpz bc-1.06.tar.gz patch -p0 < bc-lowercase-hex-hack.patch cd bc-1.06 ./configure --with-readline make sudo mv bc/bc /usr/local/bin/xc
Tags: hexadecimal debugging bc
Posted at 10:06AM Sep 17, 2009
by simmons in General |
Comments[0]