Next: , Previous: Types and Fields, Up: Field Types

### 6.3 Scalar Field Types

The rec format supports the declaration of fields of the following scalar types: integer numbers, ranges and real numbers.

Signed integers are supported by using the `int` declaration:

```     %typedef: Id_t int
```

Given the declaration above, fields of type `Id_t` must contain integers, and they may be negative. Hexadecimal values can be written using the `0x` prefix, and octal values using an extra `0`. Valid examples are:

```     %type: Id Id_t

Id: 100
Id: -23
Id: -0xFF
Id: 020
```

Sometimes it is desirable to reduce the range of integers allowed in a field. This can be achieved by using a range type declaration:

```     %typedef: Interrupt_t range 0 15
```

Note that it is possible to omit the minimum index in ranges. In that case it is implicitly zero:

```     %typedef: Interrupt_t range 15
```

It is possible to use the keywords `MIN` and `MAX` instead of a numeral literal in one or both of the points conforming the range. They mean the minimum and the maximum integer value supported by the implementation respectively. See the following examples:

```     %typedef: Negative range MIN -1
%typedef: Positive range 0 MAX
%typedef: AnyInt range MIN MAX
%typedef: Impossible range MAX MIN
```

Hexadecimal and octal numbers can be used to specify the limits in a range. This helps to define scalar types whose natural base is not ten, like for example:

```     %typedef: Address_t range 0x0000 0xFFFF
%typedef: Perms_t range 755
```

Real number fields can be declared with the `real` type specifier. A wide range of real numbers can be represented this way, only limited by the underlying floating point representation. The decimal separator is always the dot (`.`) character regardless of the locale setting. For example:

```     %typedef: Longitude_t real
```

Examples of fields of type real:

```     %rec: Rectangle
%typedef: Longitude_t real
%type: Width  Longitude_t
%type: Height Longitude_t

Width: 25.01
Height: 10
```