Calculators are so ubiquitous and so familiar that they are easy to take for granted in many different ways. [lcamtuf] points out one that has probably never occurred to many of us: the user interface for a calculator is an unexpectedly complex thing.

Resolving something like 1 + 2 = is pretty straightforward but complexity compounds rapidly after that, with numerous special cases. Let’s imagine one decides to program a simple calculator UI as a weekend project. The development process might look a little like this:
- User types in
1 + 2 =and the calculator displays3. What happens if the user immediately presses-? - No problem, just consider the result of the previous operation as an already-there input. So we’ll have
3 -for this next operation, and wait for more. - Unless we should have treated that
-as a negative sign for whatever number is coming next, making it a negative number? No, ignore that. Just treat whatever results from pressing equals as a pre-typed input. - Unless the user hits a number. Because if they hit
2(for example) then we’ll have a32and not a2which they probably, definitely don’t expect. So that’s a special case and we should insert a clear if that happens. - Oh, better clear if the user enters a decimal, too.
- I’m going to need a coffee…
And that’s just the tip of the iceberg. Imagine trying to figure all this out for the very first time, without the benefits of habit and history to fall back on.
The fact is that supporting the apparently trivial behavior of a simple calculator requires an underlying complex state machine that deals with all kinds of special cases in order to make the UI feel intuitive. And that’s just for a basic four-function calculator; we haven’t even touched on how special keys like % should behave.
We know [lcamtuf] speaks from experience, not just because of their deep knowledge of calculator history but because they rolled their own calculator that uses voltmeters as digit displays and there’s nothing like actually implementing something to make one appreciate it.

Bla bla bla why not just use RPN like we nerds did since before we even learned to speak. This is superior and the only sane way to do math.
#2: What if I want to subtract a negative number from 3? 3 – – |number|?
3 – |number| [+/-]
There is an explicit key [+/-] for toggling the sign on the calculator pictured in the article.
That had me confused…. calulators have a dedicated +/- key, toggle the sign… it’s even in the picture.
I picked up a calculator in the 80’s as a kid, don’t recall ever being confused about it.
What had me confused was the next generation, that tried to be like a commandline, but not really, with a cursor, wanna be code, that executes on equal… cringe.
If I wanted to write code I write code, my calculator executes, is the ALU, I do the ordering.
The joys of designing a calculator from scratch: https://saccade.com/writing/projects/CS428/WireWrap.html
I found it really simple to write a quite complex calculator.
I mean: I didn’t find it hard at all to ask Claude to write the code. I just specified what I wanted, and Claude filled in the blanks and wrote the code. It even wrote unit tests. And it did make a number of wrong assumptions that I had to correct. It also hadn’t properly taken the case “X – -Y” into consideration, but all that was corrected really easily.
I am not joking. In 2026, writing a calculator state machine is effortless. We’re standing on the shoulders of taller giants than ever.
Funny, that quote with that smiley, in the middle of my comment was supposed to be the smirking emoticon > : )
That. XY … that old/basic calculator has no stack. When you can only hold a single value in the background… all else follows…
I discovered two shortcuts on my Sears (Bowmar) 4-banger:
N × = would give N squared
N ÷ = would give 1/N