Standards /

WCPS-Manual / Range Types

A range type t1 is said to be cast-compatible with a range type t2 iff the following conditions hold:

  • Both range types, t1 and t2, have the same number of field elements, say d;
  • For each range field element position i with 1≤i≤d, the ith range field type f1,i of t1 is cast-compatible with the ith range field type f2,i of t2.

A range field type f1 is said to be cast-compatible with a range field type f2 iff f2 can be cast to f1, whereby casting of f2 to f1 is defined as looking up f2 in the Table below and replacing it by its right-hand neighbour type or, if it is the last type in line, by the first type of the next line. This is repeated until either f1 is matched, or the end of the Table below is reached. Type f1 can be cast to type f2 if the casting procedure terminates with finding t2, otherwise the cast is not possible.

Example

For three single-field coverages F, I, and B with range types float, integer, and Boolean, resp., the result type of the following expression is float:

F + I + B

Extending Boolean to (signed or unsigned) short shall map false to 0 and true to 1.

Type extension rules:

Boolean > char
char > Boolean
Boolean > unsigned char
unsigned char > Boolean
char > short
char > unsigned short
unsigned char > short
unsigned char > unsigned short
short > int
short > unsigned int
unsigned short > int
unsigned short > unsigned int
int > long
int > unsigned long
unsigned int > long
unsigned int > unsigned long
long > float
float > double
float > complex
double > complex2
complex > complex2

Example

For a Boolean single-field coverage B, and an integer single-field coverage I, the following expression will evaluate to some integer value:

count( I * B )

Before executing any binary operation where the two operands are of different type a cast operation shall be attempted to achieve equal types. If a cast is attempted or implicitly needed, but not possible according to the above rules, then an exception shall be reported.

Note: The cast operation is the same as in programming languages and database query languages.