Ada Programming/Attributes/'Machine Emax

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Ada. Time-tested, safe and secure.

Description[edit | edit source]

X'Machine_Emax 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_Emax returns the largest exponent.

Example[edit | edit source]

with Ada.Text_IO;

procedure Machine_Emax is

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

end Machine_Emax;

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

Emax of Float type       =         128
Emax of Long_Float type  =        1024

See also[edit | edit source]

Wikibook[edit | edit source]

Ada Reference Manual[edit | edit source]