next up previous
Next: 4.2 Arithmetic Functions and Up: 4. ARITHMETIC IN LISP Previous: 4. ARITHMETIC IN LISP

4.1 Reading and Printing Numbers.

Numbers are stored in the computer as though they were a special type of atomic symbol. This is discussed more thoroughly in section 7.3. The following points should be noted:

1. Numbers may occur in S-expressions as though they were atomic symbols.

2. Numbers are constants that evaluate to themselves. They do not need to be quoted.

3. Numbers should not be used as variables or function names.

a. Floating-Point Numbers

The rules for punching these for the read program are:

1. A decimal point must be included but not as the first or last character.

2. A plus sign or minus sign may precede the number. The plus sign is not required.

3. Exponent indication is optional. The letter E followed by the exponent to the base 10 is written directly after the number. The exponent consists of one or two digits that may be preceded by a plus or minus sign.

4. Absolute values must lie between 2128 and 2-128 (1038 and 10-38).

5. Significance is limited to 8 decimal digits.

6. Any possible ambiguity between the decimal point and the point used in dot notation may be eliminated by putting spaces before and after the LISP dot. This is not required when there is no ambiguity.

Following are examples of correct floating-point numbers. These are all different forms for the same number, and will have the same effect when read in.

60.0 
6.E1 
600.00E-1 
0.6E+2

The forms .6E+2 and 60. are incorrect because the decimal point is the first or last character respectively.

b. Fixed-Point Numbers

These are written as integers with an optional sign.

Examples

        -17 
        32719

c. Octal Numbers or Logical Words

The correct form consists of

1. A sign (optional). 2. Up to 12 digits (0 through 7). 3. The letter Q. 4. An optional scale factor. The scale factor is a decimal integer, no sign allowed.

Example

        a. 777Q 
        b. 777Q4 
        c. -3Q11 
        d. -7Q11 
        e. +7Q11

The effect of the read program on octal numbers is as follows.

1. The number is placed in the accumulator three bits per octal digit with zeros added to the left-hand side to make twelve digits. The rightmost digit is placed in bits 33-35; the twelfth digit is placed in bits P, 1, and 2.

2. The accumulator is shifted left three bits (one octal digit) times the scale factor. Thus the scale factor is an exponent to the base 8.

3. If there is a negative sign, it is OR-ed into the P bit. The number is then stored as a logical word.

The examples a through e above will be converted to the following octal words. Note that because the sign is OR-ed with the 36th numerical bit c. d, and e are equivalent.

a. 000000000777 
b. 000007770000 
c. 700000000000 
d. 700000000000 
e. 700000000000


next up previous
Next: 4.2 Arithmetic Functions and Up: 4. ARITHMETIC IN LISP Previous: 4. ARITHMETIC IN LISP