Marco’s Object Oriented calculator
moo is a simple calculator that accepts C-like syntax as input. Calculations are done on expr, if given. Otherwise, the standard input is used.
Numbers can be entered in hexadecimal (0xbeef), decimal (1984), octal (007), and binary (0b1001). All numerical operators (+, -, *, /, %), bit operators (|, ^, &, ~, <<, >>), and logical operators (==, !=, <, >, <=, >=, !, &&, ||) are supported.
moo is released into the public domain.
-
moo 1.3
Changes:
- If only one number is input, print results in all bases. (From Pierre Riteau <pierre dot riteau at free dot fr>, thanks!).
- Tokenize everything. Don't skip stuff that's not tokenized.
- Enable all regression tests; I had forgotten I disabled them. Update tests to 64-bit goodness. Make it possible to override REGRESS_TARGETS on command line.
Changes:
- Change internal storage from int to int64_t. (Thanks mbalmer@!)
- Prevent division by zeroes. (Thanks again mbalmer@!)
Changes:
- Add regression tests, which caught the bugs below.
- Fix some precedence bugs. (|| had highest precedence, followed by &&.)
- Fix some bugs when printing 0 in different bases. (“0” was printed as hex and octal, “0b” was printed as binary.) Now “0x”, “0”, and “0b” will always prefix hexadecimal, octal, and binary numbers.
- moo 1.0