Previous Table of Contents Next


FLOAT operator is defined as

   FLOAT  (x: INTEGER; T: Type := REAL)  : T
          (x: Float; T: Type := REAL)    : T

FLOAT(x, T) is a floating-point value of type T that is equal to or very near x. The type T must be a floating-point type; it defaults to REAL. The exact semantics depend on the thread’s current rounding mode, as defined in the required interface FloatMode (see section 11.10.6).

FLOOR and CEILING operators are defined as

   FLOOR    (x: Float)  : INTEGER
   CEILING  (x: Float)  : INTEGER

FLOOR(x) is the greatest integer not exceeding x. CEILING(x) is the least integer not less than x.

ROUND and TRUNC operators are defined as

   ROUND   (r: Float)  : INTEGER
   TRUNC   (r: Float)  : INTEGER

ROUND(r) is the nearest integer to r; ties are broken according to the constant RoundDefault in the required interface FloatMode. TRUNC(r) rounds r toward zero; it equals FLOOR(r) for positive r and CEILING(r) for negative r.

MAX and MIN operators are defined as

   MAX, MIN  (x,y: Ordinal)  : Ordinal
             (x,y: Float)    : Float

MAX returns the greater of the two values x and y; MIN returns the lesser. If x and y are ordinals, they must have the same base type, which is the type of the result. If x and y are floats, they must have the same type, and the result is the same type as both.

11.8.11. Relations

Operators = and # are defined as

   infix   =, #  (x, y: Any)  : BOOLEAN

The operator = returns TRUE if x and y are equal. The operator # returns TRUE if x and y are not equal. It is a static error if the type of x is not assignable to the type of y or vice versa.

Ordinals are equal if they have the same value. Floats are equal if the underlying implementation defines them to be; for example, on an IEEE implementation, +0 equals -0 and NaN (not a number) does not equal itself. References are equal if they address the same location. Procedures are equal if they agree as closures—that is, if they refer to the same procedure body and environment. Sets are equal if they have the same elements. Arrays are equal if they have the same length and corresponding elements are equal. Records are equal if they have the same fields and corresponding fields are equal.

Operators <= and >= are defined as

   infix  <=, >=  (x,y: Ordinal)    : BOOLEAN
                  (x,y: Float)      : BOOLEAN
                  (x,y: ADDRESS     : BOOLEAN
                  (x,y: Set)        : BOOLEAN

In the first three cases, <= returns TRUE if x is at most as large as y. In the last case, <= returns TRUE if every element of x is an element of y. In all cases, it is a static error if the type of x is not assignable to the type of y or vice versa. The expression x >= y is equivalent to y <= x.

Operators < and > are defined as

   infix  >, <  (x,y: Ordinal)  : BOOLEAN
                (x,y: Float)    : BOOLEAN
                (x,y: ADDRESS)  : BOOLEAN
                (x,y: Set)      : BOOLEAN

In all cases, x < y means (x <= y) AND (x # y), and x > y means y < x. It is a static error if the type of x is not assignable to the type of y or vice versa.

Note that with IEEE floating-point, x <= y is not the same as not x > y.

Operator IN is defined as

   infix  IN    (e: Ordinal; s: Set)    : BOOLEAN

IN returns true if e is an element of set s. It is a static error if the type of e is not assignable to the element type of s. If the value of e is not a member of the element type, no error occurs, but IN returns FALSE.

11.8.12. Boolean Operations

The following are some examples of Boolean operators:

   prefix   NOT   (p: BOOLEAN)    : BOOLEAN
   infix    AND   (p,q: BOOLEAN)  : BOOLEAN
   infix    OR    (p,q: BOOLEAN)  : BOOLEAN

NOT p is the complement of p.

p AND q is TRUE if both p and q are TRUE. If p is FALSE, q is not evaluated.

p OR q is TRUE if at least one of p and q is TRUE. If p is TRUE, q is not evaluated.


Previous Table of Contents Next