The text read off it
[page 18]
SET DISCOUNT = ORDER.AMOUNT * DISCOUNT.PERCENTAGE.
In this case, the system would take the value in the ORDER.AMOUNT field, look up the value in the field called DISCOUNT.PERCENTAGE, multiply the two values together, and store the result, as before, in the DISCOUNT field.
The same result is obtained in either case, and it may appear at first sight that it is more efficient to write literals than named constants. This may or may not be so. If the constant is short, as in this example, it will usually be more convenient to write it as a literal. If it is long, and if it can be given a short name, it may be more efficient to treat it as a named constant. Furthermore, the technique of naming a constant makes it possible to store large quantities of reference material, such as lists and tables, within the system, and to make use of selected items from such a list or table as required. The reader will see later how this may be done.
It should be noted, however, that in certain special cases the name of a named constant is implied, rather than actually written. In such a case, the constant will be a part of a data item which is named, and it will always be possible to identify it by making an appropriate reference to the named item. The reader will see, in the discussion of tables, that each individual item in a table need not be named, but the table itself (and, often, specific kinds of data within the table) will be named. The programmer can then refer to subordinate elements in the table by a kind of indexing known as "subscripting." This is explained later in this chapter.
Literals
Although a literal may be written and used in a procedure statement as if it were a data-name, it differs from data-names (including named constants) in that its value is the value literally stated—it is not used as a name for some other value.
Rules for Forming Literals
Literals may be numeric, alphabetic, or alphameric. Some of the rules for forming numeric literals differ slightly from the rules for alphabetic and alphameric literals. For convenience of reference, the rules governing each type are listed separately.
NUMERIC LITERALS
- All literals are limited to 50 characters in length, and, when written on the columnar form used for writing procedure statements, they may not be carried over from one line to the next.
- Numeric literals may contain only numerals, not more than one decimal point, and a plus or minus sign to indicate whether the value of the number is positive or negative. "Floating point" numbers also contain the letter F, as explained in Rule 4 below, and may contain more than one plus or minus sign. The decimal point is required except where it would be the last character of the literal; in that case it must not be used. The decimal point will be noted by the system in order to align the number properly for use, but it will not occupy an actual place in storage, and it is not counted in determining the length of the literal.
- If the literal is to be operated on arithmetically, it must contain not more than 20 digits.
- Numeric values may be entered as "floating point" numbers by writing the "fraction" (i.e., the number or decimal fraction), then the symbol F, and then the exponent. The fraction and the exponent may each have a plus or minus sign. The symbol F will not occupy a space in storage, and it is not counted in determining the length of the literal. The system will accept floating point numbers using a base of 10 only. (A floating point number is a number expressed as a decimal number or decimal fraction multiplied by some power of 10. For example, the number 1500 might be written as
1.5F3, which is equivalent to 1.5 times 10³; the same number might also be written as15F2,.15F4, or in any other similar way that is convenient. The number .002, which is equivalent to 2 times 10⁻³, might be written2F-3.) - Numeric literals must not be enclosed in quotation marks.
