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.

<strong>PASCAL</strong> DATA TYPES<br />

In addition to decimal notation, <strong>PASCAL</strong> allows you to specify integer<br />

constants in binary, octal, and hexadecimal notation. You can use<br />

constants written in these notations anywhere that decimal integer<br />

constants are permitted.<br />

To specify an integer constant in binary, octal, or hexadecimal<br />

notation, place a percent sign (%) and a letter in front of a number<br />

enclosed in apostrophes. The appropriate letters, which can be either<br />

uppercase or lowercase, are B for binary notation, 0 for octal<br />

notation, and X for hexadecimal notation. An optional plus or minus<br />

sign can precede the percent sign to indicate a positive or negative<br />

value. Note that regardless of which notation you use, the value can<br />

not exceed MAXINT, for example:<br />

-%B'111001'<br />

%b'10000011'<br />

%0'7712'<br />

-%0'473'<br />

+%X'53Al'<br />

-%x'DEC'<br />

2.2.1.2 REAL Data Type - The reserved words REAL, SINGLE, and DOUBLE<br />

denote the real number types. In <strong>PASCAL</strong>, a real number can range from<br />

+-0.14*10**-38 through +-3.4*10**38, with a typical precision of eight<br />

decimal digits. REAL and SINGLE are synonymous; both have<br />

single-precision real number va]ues. The type DOUBLE allows you to<br />

declare double-precision real variables. You can assign real and<br />

integer values to a variable of type REAL, SINGLE, or DOUBLE. If you<br />

assign an integer value to a variable of type REAL, <strong>PASCAL</strong> converts<br />

the integer to a real number.<br />

In a <strong>PASCAL</strong> program, you can write real numbers in two ways; fixed on<br />

floating point. With fixed point notation, you write the number with<br />

the decimal point exactly where it appears in the value. The first<br />

way is the following form:<br />

2.4<br />

893.2497<br />

-0.01<br />

8.0<br />

-23.18<br />

0.0<br />

Note that, in this form, at least one digit must appear on each side<br />

of the decimal point. That is, a zero must always precede the decimal<br />

point of a number between 1 and -1, and a zero must follow the decimal<br />

point of a whole number.<br />

Some numbers, however, are too large or too small to write<br />

conveniently in the above format. <strong>PASCAL</strong> provides scientific (also<br />

known as exponential) notation as a second way of writing real<br />

numbers. In scientific notation, you write the number as a positive<br />

or negative value followed by an exponent, for example:<br />

2.3E2<br />

-0.07E4<br />

10.0E-1<br />

-<strong>20</strong>1E+3<br />

-2.14159£0<br />

2-3

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

Saved successfully!

Ooh no, something went wrong!