18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

quantities is an attractive idea. However, both the range and number of real numbers are infinite,<br />

while a computer has a finite range of representations.<br />

The enumeration of items, or iterations, requires the exact representation of a sizable range of integer<br />

numbers. Many other calculations require the representation of a potentially greater range in<br />

magnitude of the real numbers but are necessarily limited in accuracy.<br />

Most computer systems, therefore, provide two internal representations for numeric data — one<br />

trading some exactness of representation for increased range. These representations may vary between<br />

different computer systems. The precise limitations pertaining to any <strong>SIMSCRIPT</strong> <strong>II.5</strong> implementation<br />

may be found in the appropriate user's guide. A programming language is used to<br />

describe both the actions and the data on which these actions are to be performed. In this chapter,<br />

some of the ways in which data are described are discussed.<br />

A variable definition statement serves to declare the properties of a variable. This information is<br />

used to determine the way in which the variable may be manipulated.<br />

2.2.1 REAL and INTEGER Variables<br />

<strong>SIMSCRIPT</strong> <strong>II.5</strong> numeric variables may be declared to be integer or real. Variables declared<br />

as integer represent only whole numbers. Variables declared as real represent numbers that can<br />

have fractional values. Note that a whole number, lying within an established range of the integer<br />

values, may be represented either by an integer or real variable. It is the possibility of a fractional<br />

value, and not any particular value, that makes a variable require a real definition. The<br />

numbers 56, -6745, 91, -1, and 0 are integer-valued. The numbers 56.0, 35.7846, 0.999876, -<br />

27.45, and 0.0. are real-valued.<br />

Every <strong>SIMSCRIPT</strong> <strong>II.5</strong> program has a preamble that contains variable definition information. In<br />

some cases, as in the previous examples, this preamble is implied but need not be written as all<br />

variables are treated as real. Whenever a variable has a property that differs from one that<br />

<strong>SIMSCRIPT</strong> <strong>II.5</strong> assumes, a variable definition statement must be used. Programs containing an<br />

explicit preamble begin with the one-word statement preamble. This section, containing variable<br />

definition statements, is separated from succeeding program action statements by the word end.<br />

As stated, the mode of a numeric variable is assumed real unless otherwise specified. The "normal<br />

form" of <strong>SIMSCRIPT</strong> <strong>II.5</strong> variables is real numbers. The assumed real condition can be changed<br />

by using the statement:<br />

mode is integer<br />

This statement resets the compiler's "background conditions" so that all following program variables<br />

are assumed integer unless otherwise specified. Mode is but one of several properties that<br />

can be used to describe variables. Hence, the general form of the normally statement is:<br />

normally, specification phrase list<br />

38

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

Saved successfully!

Ooh no, something went wrong!