Types of Storage



A telephone has a working storage location, which is the one where a number resides for dialing. It may also have permanent storage locations where other numbers may be placed and "Recalled" into the "working storage" area. There is another type of storage, termed temporary storage, the nature of which may be described as for a simple calculator.

It is convenient in this instance to envision a "hidden" storage area situated above the one where numbers are seen as entered. When the calculator is turned on both of these locations are empty. Entering a number fills the working storage area. Putting in a second number to do a calculation, though, requires a "cue" that the number to be entered is to be used with the first. Depending on manufacturer this may be to simply key in +, -, × or ÷. Alternatively, it may be necessary to first key in "Enter", then designate the mathematical operation later. The example calculator will use the first method, and "op" should be understood as representing either +, -, ×, or ÷. Upon hitting "=" whatever mathematical operation is specified is performed and the result displayed in the working storage location. The temporary storage location is cleared when the operation is done.

 
 
-->
 
1st No.
op
-->
1st No.
2nd No.
=
-->
 
Result


A calculator with memory storage can have any stored value brought to the visible working storage area in the same way as was done for the telephone. Conversely, any number in the visible area can be stored as was done for the telephone.

The visible area can be called working storage because a number entered there can also have other operations performed on it. For example, the square root or the log of it may be obtained by tapping the appropriate key. These are called "functions" (Note: A definition more suited to JS will be given shortly.). They take the number entered and, using built-in procedures, arrive at the answer which is then displayed in the same window. Computers also have built in functions to do the same kind of thing, and many more as well. They are given names which are reserved words for JS purposes and must not be used as a name for a variable.

Storing a number using JS coding is a relatively simple task. A name is first decided upon, usually something pertinent or descriptive in relation to what is being done. This is designated as being a variable, var, and the value given. For example, net income is determined as the difference between gross income, say 120000, and costs, say 850.00. Neglecting the monetary sign, $, which can always be edited in, this calculation can be coded as follows:

var gross=1200.00;
var costs=850.00;
 
net=gross-costs;


Two things should be noted here. "Var" designates that the name that follows is a variable and the statement of its value ended with a semi-colon. A statement is a line of code and always ends with a semi-colon, ; , designating "end-of-code".

What is being done here is: each of the numbers are being placed in the storage areas named. The construct of most computer languages is to have whatever is to be done with the numbers mathematically expressed as would be done in an equation. The actual calculation is automatic. Those variables in the equation take their numbers from storage locations of the same name which have been previously filled with a value. All of this takes place to the right of the "=" sign in the statement. The name to the left of the "=" sign is the storage area identifier for the result. Intermediate results as may be necessary for the calculation are automatically stored in "hidden" locations and automatically brought in as needed.

There are also "functions" like square root and log in JS. These are "built-in" as a collection of evaluators in a core called a math object. The evaluator is not termed a "function" but rather a method. Many of these evaluators make use of fundamental mathematical values like square-root, pi, or log and these are called properties. The use of some methods is illustrated below:

Take square-root of 256root=math.sqrt(256);
Find log (natural) of 32.56 result=math.log(32.56);


The number which is to be evaluated is placed in parenthesis for the particular evaluator being used. The evaluator is prefaced by "math." to designate the evaluator is drawn from the built-in object library. It is sufficient to just take note of these JS descriptions right now.

<< PreviousNext >>