411 REFERENCE · Wikibooks
Ada Programming/Attributes/'Machine Radix
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Attributes 'Machine_Radix
__TOC__
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
with Ada Text_IO;
procedure Machine_Radix is
package T_IO renames Adadot .Text_IO;
package I_IO is new Adadot .Text_IOdot .Integer_IO (Integer);
type My_Fixed_Point_Type is delta 0dot .1 range -1dot .0 double_dot .. 1dot .0;
type My_Decimal_Type is delta 0dot .01 digits 10;
begin
T_IOdot .Put ("Radix of Float type = ");
I_IOdot .Put (Float'Machine_Radix);
T_IOdot .New_Line;
T_IOdot .Put ("Radix of My_Fixed_Point_Type = ");
I_IOdot .Put (My_Fixed_Point_Type'Machine_Radix);
T_IOdot .New_Line;
T_IOdot .Put ("Radix of My_Decimal_Type type = ");
I_IOdot .Put (My_Decimal_Type'Machine_Radix);
T_IOdot .New_Line;
end Machine_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
Ada Reference Manual
A 5 3 Attributes of Floating Point Types
A 5 4 Attributes of Fixed Point Types
K Language-Defined Aspects and Attributes
Address
Address