Ada 编程/属性/'机器基数
外观
X'Machine_Radix 是一个 Ada 属性,其中 X 是任何浮点或定点类型。它返回类型 X 的硬件表示的基数。在大多数机器上,这将是 2。
Machine_Radix 也是一个 Ada 方面,可以通过属性定义子句为十进制定点类型设置。该值被限制为 2 或 10。
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'Machine_Radix); T_IO.New_Line; T_IO.Put ("Radix of My_Fixed_Point_Type = "); I_IO.Put (My_Fixed_Point_Type'Machine_Radix); T_IO.New_Line; T_IO.Put ("Radix of My_Decimal_Type type = "); I_IO.Put (My_Decimal_Type'Machine_Radix); T_IO.New_Line;endMachine_Radix;
在 x86-64 架构上使用 GNAT 4.6 的输出是
Radix of Float type = 2 Radix of My_Fixed_Point_Type = 2 Radix of My_Decimal_Type type = 2
