content_image/836663.jpg
## Produces as results: 

Yesterday Saturday -1 Tomorrow Monday 1 Today Sunday 0 

## S.B. Subrange Types 

A type may be defined as a subrange of any other previously defined ordinal type - called its host type. The definition of a subrange simply indicates the least and the largest constant value in the subrange, where the lower bound must not be greater than the upper bound. A subrange of the type Real is not allowed, because real is not an ordinal type. 

<img src='content_image/836663.jpg'>

The host of the subrange type determines the validity of all operations involving values of the subrange type. Recall that ordinal-type assignment compatibility assumes that the variable and the expression are the same or subranges of the same ordinal type, and the value of the expression lies within the closed interval specified by the type of the variable. For example, given the declaration: 

var A: 1. .10; B: O .. 30; c: 20 .. 30; 

The host type for A, B, and c is Integer. Hence the assignments 

A := B; C:= B; B:= C; 

are all valid statements, although their execution may sometimes be an error. Whenever ordinal types are discussed throughout this text, the phrase "or subrange thereof' is therefore assumed to be implied and is not always mentioned. 

