IEEE Std 754-2019 pdf download
IEEE Std 754-2019 pdf download.IEEE Standard for Floating-Point Arithmetic.
4. Attributes and rounding
4.1 Attribute specification
An attribute is logically associated with a program block to modit’ its numerical and exception semantics. A user can specil’ a constant value for an attribute parameter.
Some attributes have the effect of an implicit parameter to most individual operations of this standard; language standards shall specify
— rounding-direction attributes (see 4.3) and should specify
— alternate exception handling attributes (see Clause 8).
Other attributes change the mapping of language expressions into operations of this standard; language standards that permit more than one such mapping should provide support for:
— preferredWidth attribut (see 10.3)
— value-changing optimization attributes (sec 10.4)
— reproducibility attributes (see Clause 11).
For attribute specification, the implementation shall provide language-defined means, such as compiler directives, to specify a constant value for the attribute parameter for the operations in a block; the scope of the attribute value is the block with which it is associated. Language standards shall provide for constant specification of the default and each specific value of the attribute.
4.2 Dynamic modes for attributes
Attributes in this standard shall be supported with the constant specification of 4.1. Particularly to support debugging, language standards should also support dynamic-mode specification of attributes.
With dynamic-mode specification, a user can specify that the attribute parameter assumes the value of a dynamic-mode variable whose value might not be known until program execution. This standard does not specify the underlying implementation mechanisms for constant attributes or dynamic modes.
For dynamic-mode specification, the implementation shall provide language-defined means to special that the attribute parameter assumes the value of a dynamic-mode variable for the operations within the scope of the dynamic-mode specification in a block. The implementation initializes a dynamic-mode variable to the default value for the dynamic mode. Within its language-defined (dynamic) scope, changes to the value of a dynamic-mode variable are under the control of the user via the operations in 9.3. 1 and 9.3.2.
The following aspects of dynamic-mode variables are language-defined; language standards may explicitly defer the definitions to implementations:
— The precedence of static attribute specifications and dynamic-mode assignments.
— The effect of changing the value of the dynamic-mode variable in an asynchronous event, such as in another thread or signal handler.
— Whether the value of the dynamic-mode variable can be determined by non-programmatic means, such as a debugger.
NOTE—A constant value for an attribute can be specified and meet the requirements of 4.1 by a dynamic mode specification with appropriate scope of that constant value.
4.3 Rounding-direction attributes
Rounding takes a number regarded as infinitely precise and, if necessary, modifies it to fit in the destination’s format while signaling the inexact exception, underfiow, or overflow when appropriate (see Clause 7). Except where stated otherwise, every operation shall be performed as if it first produced an intermediate result correct to infinite precision and with unbounded mnge, and then rounded that result according to one of the attributes in this cIaise.
Except where stated otherwise, the rounding-direction attribute affects all computational operations that might be inexact. Inexact numeric floating-point results always have the same sign as the unrounded result.
The rounding-direction attribute affects the signs of exact zero sums (see 6.3), and also affects the thresholds beyond which overflow (see 7.4) and underfiow (see 7.5) are signaled.
Implementations supporting both decimal and binary formats shall provide separate rounding-direction attributes for binary and decimal, the binary rounding direction and the decimal rounding direction. Operations returning results in a floating-point format shall use the rounding-direction attribute associated with the radix of the results. Operations converting from an operand in a floating-point format to a result in integer format or to an external character sequence (see 5.8 and 5.12) shall use the rounding-direction attribute associated with the radix of the operand.
NaNs arc not rounded (but see 6.2.3).