Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Arithmetic operators

The types of operands and results for dyadic and monadic operations shall be as shown in tables 3 and 4 respectively.

 

NOTE --- 1 The symbols +, -, and * are also used as set operators (see 6.7.2.4).

 

A term of form x/y shall be an error if y is zero; otherwise, the value of x/y shall be the result of dividing x by y.

 

Table 3 --- Dyadic arithmetic operations

Operator Operation Type of operands Type of result

+ Addition integer-type ½

or real-type ½

- Subtraction integer-type ½integer-type if both operands

or real-type ½are of integer-type

* Multiplication integer-type ½otherwise real-type

or real-type ½

/ Division integer-type real-type

or real-type

div Division with integer-type integer-type

truncation

mod Modulo integer-type integer-type

 

Table 4 --- Monadic arithmetic operations

Operator Operation Type of operand Type of result

+ Identity integer-type integer-type

real-type real-type

- Sign-inversion integer-type integer-type

real-type real-type

 

A term of the formi div j shall be an error if j is zero; otherwise, the value of i div j shall be such that

abs(i) - abs(j) < abs( (i div j) * j) <= abs(i)

where the value shall bezero if abs(i) < abs(j); otherwise, the sign of the value shall be positive if i and j have the same sign and negative if i and j have different signs.

A term of the form i mod j shall be an error if j is zero or negative; otherwise, the value of i mod j shall be that value of (i-(k*j)) for integral k such that 0 <= i mod j < j.

 

NOTE --- 2 Only for i >= 0 and j > 0 does the relation (i div j) * j + i mod j = i hold.

 

The required constant-identifier maxint shall denote an implementation-defined value of integer-type. This value shall satisfy the following conditions.

a) All integral values in the closed interval from -maxint to +maxint shall be values of the integer-type.

b) Any monadic operation performed on an integer value in this interval shall be correctlty performed according to the mathematical rules for integer arithmetic.

c) Any dyadic integer operation on two integer values in this same interval shall be correctly performed according to the mathematical rules for integer arithmetic, provided that the result is also in this interval.

d) Any relational operation on two integer values in this same interval shall be correctly performed according to the mathematical rules for integer arithmetic.

 

Table 5 --- Set operations

OperatorOperationType of operandsType of result

+ Set union The same unpacked-canonical-set-of-T-type

- Set difference or packed-canonical-set-of-T-type Same as operands

* Set intersection (see 6.7.1)

 

The results of integer-to-real conversion, of the real arithmetic operators and of the required real functions shall be approximations to the corresponding mathematical results. The accuracy of this approximation shall be implementation-defined.



It shall be an error if an integer operation or function is not performed according to the mathematical rules for integer arithmetic.

 

Boolean operators

Operands and results for Boolean operations shall be of Boolean-type. The Boolean operators or, and, and not shall denote respectively the logical operations of disjunction, conjunction, and negation.

Boolean-expression = expression .

A Boolean-expression shall be an expression that denotes a value of Boolean-type.

 

Set operators

The types of operands and results for set operations shall be as shown in table 5.

Where x denotes a value of the ordinal-type T and u and v are operands of a canonical-set-of-T-type, it shall be true for all x that

--- x is a member of the value u+v if and only if it is a member of the value of u or a member of the value of v;

--- x is a member of the value u-v if and only if it is a member of the value of u and not a member of the value of v;

--- x is a member of the value u*v if and only if it is a member of the value of u and a member of the value of v.

 


Date: 2015-12-24; view: 1003


<== previous page | next page ==>
Transfer procedures | Procedure-statements
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.008 sec.)