411 REFERENCE · Wikibooks
Ada Programming/Attributes/'Machine Mantissa
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Attributes 'Machine_Mantissa
__TOC__
Description
X'Machine_Mantissa is an Ada attribute where X is any floating point type.
Floating point types are represented as:
where
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
with Ada Text_IO;
procedure Machine_Mantissa is
package T_IO renames Adadot .Text_IO;
package I_IO is new Adadot .Text_IOdot .Integer_IO (Integer);
begin
T_IOdot .Put ("Mantissa of Float type = ");
I_IOdot .Put (Float'Machine_Mantissa);
T_IOdot .New_Line;
T_IOdot .Put ("Mantissa of Long_Float type = ");
I_IOdot .Put (Long_Float'Machine_Mantissa);
T_IOdot .New_Line;
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
Wikibook
Ada Programming
Ada Programming/Attributes
Ada Programming/Attributes/'Machine_Emax
Ada Programming/Attributes/'Machine_Emin
Ada Programming/Attributes/'Machine_Radix
Ada Reference Manual
5 3 Attributes of Floating Point Types
K Language-Defined Attributes
Address
Address