Calculator Code: Programming Code for Use within a Scientific Calculator
Active In SP
Joined: Sep 2010
04-01-2011, 01:08 PM
The calculator is an extension of a mathematician and it has opened up new possibilities within mathematics. It is a machine though, and it is only capable of doing what it is programmed to do. Accordingly, this project and implimentation aims to develop the internal programmed computational code in the form of a computer program that a scientific calculator could use to compute functions such as square root, the exponential, and sine functions.1 The idea of this project and implimentation assumes that that the programmer has already developed the very basic addition, subtraction, multiplication, division and integer splicing2 functions. Then using these basic functions, the program will then compute other more complicated functions found on a typical scientific calculator such as the sine and logarithmic functions.
With the necessity to conform to reality, there are limitations set upon this calculator and they are similar to those found in popular calculators such as the Texas Instruments TI-83 Plus. They are that: (1) functions inputs and outputs must be calculated accurately to ten significant figures3, (2) the absolute values of inputs and outputs, excluding zero, can never be greater than or equal to 1 x 10100 or less than or equal to 1 x 10-100.
Similar to these mandatory requirements, there are a few goals that I wish to accomplish within the confines of the limitations. They are that: (1) the code is as easily programmed as possible, (2) and that the program is to be as efficient as possible at computing the functions. Every programming language has advantages and disadvantages; because I was familiar with the C++ programming language and learning a new language was beyond the scope of this project and implimentation, I chose to work within the C++ language. A few advantages with choosing this language are that the code is easily transferred into other programming languages and that it is universally known. I choose to use a Windows Console application due to its simplicity and my familiarity with it, but this is a disadvantage because it is not an optimal interface for a calculator due to its lack of visual resemblance of a handheld calculator.
The interface created for user inputs and outputs was created for basic test purposes only, and if I had more time, I would have liked to use Visual Basic to create a visual calculator with buttons that were able to be pressed. Even though the created interface looks rudimentary, it contains all the possible tasks that the program is able to do. There were other programming and computations issues that needed to be taken into account as well when transferring mathematical theory into a working calculator. One issue was the large difference in computational time. Computing multiplication and division takes significantly longer time than computing addition and subtraction, and therefore should be avoided whenever possible. Thus throughout the program there are instances where addition and subtraction is used to eliminate the need for multiplication. Another issue is that the program is constantly rounding numbers and thus losing trailing digits. Therefore in some cases it is very difficult or impossible to adhere to the goals previously described. An example of this is within the modulo function which cannot be evaluated for relatively large values modulo a relatively small value.