13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

To add, subtract, or multiply two integer, integer subrange, real, or longinteger expressions, place the +, - , or * operator between them:X-Y X-CY+Z) 3.14159*XTRUNCCX>*YCX+3>*ABSCY-CX"Z)Some combinations of numerical types are illegal under these operations,however. Here are the rules:o Every negation is legal. The result of negating an integer subrange is aninteger expression; with other types, the result is the same type.o Every combination of two integer, two real, or two long integerexpressions is legal, provided the actual result is within the value rangefor that type. A real result below the lower limit of real values is legal; itis treated as 0.0.o Every combination of integer and integer subrange expressions is legal,provided the actual result is within the integer value range. The result isan integer expression.o Every combination of integer (or integer subrange) and real expressionsis legal; the result is a real expression.o Every combination of integer (or integer subrange) and long integerexpressions is legal; the result is a long integer.o Every combination of real and long integer expressions is illegal.Be Careful: When constructing arithmetic expressions, analyze eachpart separately for the possibility that its value may overflow orunderflow during program execution. For example, if Xis an integer theexpressionex * 314> DIV 1e0will cause a program halt if the value of X exceeds 104 (because105 * 314 = 32970, an integer overflow). The program will halt eventhough the value of the whole expression is legal.Division and Modulus ReductionPascal provides two operators for dividing numerical expressions, and onefor reducing an integer modulo another integer:DIV/ MODTo divide any combination of integer, integer subrange, or long integerexpressions, write DIV between the dividend and the divisor. Unlike theIII-80Chapter 6: Operations on Data

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

Saved successfully!

Ooh no, something went wrong!