Ada Programming/Attributes/'Machine Mantissa

Ada. Time-tested, safe and secure.
Ada. Time-tested, safe and secure.

Description edit

X'Machine_Mantissa is an Ada attribute where X is any floating point type.

Floating point types are represented as:



sign is 1 or -1
mantissa is a fraction in base radix
radix is the hardware radix (usually 2)
exponent is an integer

'Machine_Mantissa returns the maximum number of digits in the mantissa.

Example edit

with Ada.Text_IO;

procedure Machine_Mantissa is

   package T_IO renames Ada.Text_IO;
   package I_IO is new  Ada.Text_IO.Integer_IO (Integer);
   T_IO.Put ("Mantissa of Float type       = ");
   I_IO.Put (Float'Machine_Mantissa);
   T_IO.Put ("Mantissa of Long_Float type  = ");
   I_IO.Put (Long_Float'Machine_Mantissa);

end Machine_Mantissa;

The output with GNAT 4.6 on the x86-64 architecture is:

Mantissa of Float type       =          24
Mantissa of Long_Float type  =          53

See also edit

Wikibook edit

Ada Reference Manual edit