10 February 2017 |
14 February 2017 |
I’ve been learning AngularJS, and decided to write some simple single-page apps to quickly get to grips with the new paradigm. Presented here is my first one: a simple calculator.
The calculator acts mostly like your standard primary school issue four-banger, except that it supports a wider range of values and will dip into scientific notation if its screen size is exceeded by the length of the answer.
It handles input and output as strings to simplify formatting for the “screen”. The strings are parsed into Floats for the actual mathematical operations, then the result is turned back into a string and formatted for display.
I was thinking about how I might go about implementing it in hardware as I was writing it, so it uses global variables as flags and registers and is written procedurally, rather than object oriented. In hindsight, I think doing it OO would have been a much better idea and would certainly simplify the code base. Oh well.