02.07.2013 Views

The turbo

The turbo

The turbo

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.

Part 2 Chapter 9 Predefined Data Types<br />

Now 0 has been properly defined as an integer variable, the same<br />

as the others used. But why did you decide to make them all of<br />

type I nteger? And just what does that mean, anyway? Let's look at<br />

the four basic data types of Pascal so see if you can get an answer.<br />

9.2 INTEGER<br />

You know what integers are: they're counting numbers (0, 1, 2,<br />

3, ... ) with negative numbers (-1, -2, -3, ... ) thrown in. <strong>The</strong> largest<br />

integer you can work with depends upon the amount of space<br />

used for integer variables. TURBO Pascal allocates two bytes,<br />

giving a maximum positive value of 32767 (known as Maxlnt).<br />

<strong>The</strong> maximum negative value is -(Maxlnt+1). So, TURBO Pascal<br />

allows the following range of values for integers:<br />

-38768 -38767 -38766 ... 0 ... 38768 38766 38767<br />

Remember your discussion of constants and expressions? An<br />

integer constant is simply a string of digits (no commas, please)<br />

with an optional - (minus sign) in front. An integer expression<br />

(formula) contains integer constants and/or integer variables<br />

and/or integer operators. <strong>The</strong> result of an integer expression is<br />

some integer value. Your sample program has two such<br />

expressions:<br />

a + b add the values of a and b<br />

a - b subtract the value of b from that of a<br />

You usually find expressions on the right side of assignment<br />

statements (as in your sample program). <strong>The</strong> program evaluates<br />

the expression using the current contents of any variables<br />

involved and then stores the resulting value in the variable on the<br />

left side of the :=. <strong>The</strong> integer operators that can appear in an<br />

expression are:<br />

= addition<br />

subtraction (and unary minus)<br />

* multiplication<br />

div division<br />

mod remainder<br />

9-3

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

Saved successfully!

Ooh no, something went wrong!