← all units
[ID_03] calci
⭘ STABLE · readout offline · anshdhariwal/calci
A calculator that parses full expressions instead of chaining single operations.
Problem
Most calculator clones apply one operator at a time and get order of operations wrong. Type 2 + 3 times 4 and they answer 20.
Decision
I wrote a small tokenizer and a recursive descent parser so the whole expression is evaluated with correct precedence and parentheses. The UI sends a string, the parser owns the math.
Tradeoff
A parser is more code than a switch statement over four operators. It was worth it to get a correct answer every time instead of a plausible one.