I recently went Googling for examples of calculator programs (sketches) for my Arduino Nano. I found a number of examples on how to interface an Arduino to the keyboard of an old calculator, but did not get any hits of pre-written sketches for turning an Arduino into a scientific calculator... you know, the ones with Sin, Cos, Tan, and etc. (Excepting one clever implementation of a full version of an HP 45 but it required a massive IBM PS/2 keyboard.)
Why would anyone want such a thing? The answer to this question is probably why I could not find anything on the Internet! But I had my reasons and so I was forced to write my own sketch. I sat down with paper and pencil and wrote down (while looking at my old HP instruction manual from college) and came up with a list of things I wanted: the obvious +, -, *, and / (add, subtract, multiply, and divide) and the more involved ones: Sin, Cos, Tan, SQR, Log, and so on. Then there were the nice to have power functions. Then the arcSin, arcCos, and arcTan stuff. The list got a bit long... too long to assign a single keyboard character to each operation.
Then there was the concern about how to get my input into the Arduino. Generally, one types in something and presses the Enter Key to confirm that they are finished with that entry. Then the next bit, and then the next bit... each followed with that Enter key. I'm not particularly fond of the Enter key so I wanted to send everything to the Arduino at one time: The operation to perform and one or two numbers as required. All I wanted the Arduino software to do was spit back the answer! After finishing the program, the bulk of the code is in the area of sending back things that I really did not want... for testing and such. So, I created two ways to build the application, one with all the voluminous output and one with just the answer; I call this verbose mode and the obvious non-verbose mode. Verbose mode is useful if you want the operator prompted for each value and for viewing settings such as Decimals and Degree-Radians.