Ada Programming/Attributes/'Machine Radix
Description
X'Machine_Radix is an Ada attribute where X is any floating or fixed point type. It returns the radix of the hardware representation of type X. On most machines this will be 2.
Machine_Radix is also an Ada aspect that may be set for decimal fixed point types via an attribute definition clause. The value is constrained to either 2 or 10.
Example
withAda.Text_IO;procedureMachine_RadixispackageT_IOrenamesAda.Text_IO;packageI_IOisnewAda.Text_IO.Integer_IO (Integer);typeMy_Fixed_Point_Typeisdelta0.1range-1.0 .. 1.0;typeMy_Decimal_Typeisdelta0.01digits10;beginT_IO.Put ("Radix of Float type = "); I_IO.Put (Float'); T_IO.New_Line; T_IO.Put ("Radix of My_Fixed_Point_Type = "); I_IO.Put (My_Fixed_Point_Type'); T_IO.New_Line; T_IO.Put ("Radix of My_Decimal_Type type = "); I_IO.Put (My_Decimal_Type'); T_IO.New_Line;endMachine_Radix;
The output with GNAT 4.6 on the x86-64 architecture is:
Radix of Float type = 2 Radix of My_Fixed_Point_Type = 2 Radix of My_Decimal_Type type = 2
See also
Wikibook
- Ada Programming
- Ada Programming/Attributes
- Ada Programming/Attributes/'Machine_Emax
- Ada Programming/Attributes/'Machine_Emin
- Ada Programming/Attributes/'Machine_Mantissa