Ada Programming/Types/range

A is a signed integer value which ranges from a  to a last. It is defined as

First .. Last

When a value is assigned to an object with such a range constraint, the value is checked for validity and Constraint_Error exception is raised when the value is not within to.

When declaring a range type, the corresponding mathematical operators are implicitly declared by the language at the same place.

The compiler is free to choose a suitable underlaying hardware type for this user defined type.

Working example
The following example defines a new range from -5 to 10 and then prints the whole range out.

; Range_1 Range_Type  -5 .. 10;    T_IO  Ada.Text_IO; I_IO  Ada.Text_IO.Integer_IO (Range_Type); A Range_Type I_IO.Put (         Item  => A,          Width => 3,          Base  => 10); A < Range_Type' T_IO.Put (","); T_IO.New_Line; ;    ;  Range_1;

Wikibook

 * Ada Programming
 * Ada Programming/Types
 * Ada Programming/Keywords/range

Ada Reference Manual


|Range

Programación en Ada/Tipos/Enteros