31.12.2013 Views

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EXPRESSIONS<br />

The REM operator can be used on integers of all sizes and retains the<br />

sign of the dividend. For example, the expression 5 REM 3 returns a<br />

value of 2, the expression (-5) REM 3 returns a value of -2; and the<br />

ex pre s s ion 5 REM ( - 3) ret urn s a val u E~ 0 f 2.<br />

In arithmetic expressions, <strong>PASCAL</strong> allows you to mix integers, real<br />

numbers (single and double precision), and integer subranges. When<br />

you assign the value of an expression to a variable, you must ensure<br />

that the types of the variable and the expression are compatible. In<br />

general, you can assign an integer expression to a real variable.<br />

However, you cannot assign a real expression to an integer variable.<br />

Table 3-2 Jists the type of the result for all possible combinations<br />

of arithmetic operators and operands.<br />

Table 3-2:<br />

Result Types for Arithmetic Expressions<br />

Operator<br />

(Opera t ion)<br />

Type of First<br />

Operand<br />

Type of Second<br />

Operand<br />

------.------------------------------------------------------------<br />

** INTEGER INTEGER<br />

( e x po n e n t i a t ion) INTEGER, REAL REAL, DOUBLE<br />

Type of<br />

Result<br />

INTEGER<br />

REAL<br />

DOUBLE<br />

INTEGER, REAL,<br />

DOUBLE<br />

DOUBLE<br />

* INTEGER INTEGER<br />

(mul tipl ication} INTEGER REAL<br />

INTEGER<br />

REAL<br />

REJ~L<br />

DOUBLE<br />

RE)\L, INTEGER<br />

INTEGER, REAL<br />

INTEGER, REAL,<br />

DOUBLE<br />

DOUBLE<br />

REAL<br />

DOUBLE<br />

DOUBLE<br />

/ RE1\L, INTEGER REAL, INTEGER<br />

(division) DOUBLE INTEGER, REAL,<br />

DOUBLE<br />

RE1\'L, INTEGER DOUBLE<br />

DIV, MOD, REM INTEGER INTEGER<br />

REAL<br />

DOUBLE<br />

DOUBLe<br />

INTEGER<br />

3-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!