c - a command-line calculator

"c" was written to both as a first test of lex/yacc and as a useful tool to do floating-point calculations on the command line. It was written in 1994 and I still use it regularly. "c" can handle the four basic operators, and comparisons like "<", ">" and "=", OR and AND. Parentheses are used to group subexpressions, and normal operator precedence is in force. It can read hexadecimal (start with "0x"), binary (start with "0b") and octal numbers (start with "0"). It also knows the functions "sin", "cos", "sqrt", "tan", "atan", "log", "ln" and "log2", each preceded by a "&" sign.

"c" can handle variables. A variable can be assigned a value using the Pascal-like syntax ":=". This is of limited value, unless the program has access to a writable file to store variables - the default /etc/cvar.val is defined in hc.h. If the program can read and write to this file, variables will be saved between invocations.

Note that the shell will force you to "escape" certain characters. You can always put the entire expression within quotes, or else escape asterisks and other special chars with a "\". Here's an example invocation:

$ c "&sqrt(&sin(5 * 10 + 0.5))"
0.482052

The source and binary distributions are hosted on my Artifactory server

.