Scientific Calculator Program by: Warren A. Smith
This program is only marginally intended to replace a
scientific calculator. Because of the limited accuracy available
from a 32 bit representation of real numbers (as all numbers are
treated in this program) this program has only limited use as a
true calculator. However, it does perform most trigonometric functions
as well as a few others and you may find these useful at times.
The input is an equation where functions are expressed by name
(or more appropriately by mnemonic) and whose arguements follow within
parenthesis. An expample would be - 4.4 * 3.6/sqrt(4.6)
Blanks do not matter (except of course in the middle of a name) and
upper and lower case alpha is interchangeable.
Normal algebraic precedence is followed with unary minus having
the highest, followed by parenthesis, followed by exponentiation '^',
and then multiplication and division '*', '/' having equal precedence.
Addition and subtraction also have equal precedence below multiplication
and division.
Typing in a question mark in response to a request for an
expression will give you a list of the currently implemented functions
along with their appropriate mnemonics.
Typing in an exclamation point will cause the program to
print out intermediate results on its way to the answer. A second
exclamation point will turn this feature off.
The main reason for writting this program was as an exercise
in recursion and parsing of input strings. I took as a flow chart
the Pascal syntax diagrams for a simple expression and extended the
idea to include exponentiation. If you investigate the source code
which I hope everyone will, you will see that it is relatively easy
to add functions to the acceptable input. You can add functions
with one arguement and with no arguements (the way Pi is treated)
simply. If you need a function with two or more arguements, you
are going to have to rethink the section within Factor that is res-
ponsible for functions. It should not take any major rewritting, only
additions.
Good luck and let me know if you come up with any improvements
or functional additions. You can reach me at:
6150 First Ave.
Sacramento, CA 95817