Re:Show HN: Calc, a simple command-line calulator in C
by jhallenworld on Tuesday June 09, 2015 @08:06AM
(#9685358)
Actually strtod will convert 0x to hex.. It would be nice if it had an option to ignore commas.
Two weeks ago, after becoming fed up with having to copy and paste results from one line to the next, I wrapped it in a repl and added bc(1)-like support for "." expanding to the last value. Rather embarrassingly, I started to implement bc(1)-style variables, but then realized this was incredibly silly as you can simply use perl variables directly. :-)
https://github.com/mct/junkdrawer/commits/master/bin/calc
I fully support writing other calc implementations, especially in languages such as C! It's a great exercise, and can become very complex very quickly. bc(1) supports arbitrary precision (try: echo "scale=500; 4a(1) 42" | bc -l), which is super awesome. In C, I've only implemented RPN calculators, never infix, which would be fun to try.