Decimal floating-point built-in functions
Decimal floating-point built-in functions are provided for each DFP hardware instruction. XL C/C++ developers can use the decimal floating-point built-in functions and macros, or named constants, by calling the functions with appropriate parameters. It is not necessary to include a header file before using decimal floating-point built-in functions. They will be automatically defined by the compiler when DFP is enabled.
All decimal floating-point built-in functions require a hardware level of at least ARCH(7).
Single precision support is limited, as noted in Table 1.
PROTOTYPE and Notes® | Description |
---|---|
|
These functions return the absolute value of the parameter. |
|
These functions return the absolute value of the first parameter, with the sign of the second parameter. |
|
These functions create quiet or signaling NaNs of the specified precision, with positive signs and zero payloads. |
The functions __d64_integral and __d128_integral allow an inexact exception. The instruction M4 bit 21 is set to 0. The functions __d64_integral_no_inexact and __d128_integral_no_inexact suppress any inexact exception. The instruction M4 bit 21 is set to 1. All these functions set the instruction M4 bit 20 to 0. If the input is a signaling NaN it is converted to a quiet NaN. |
These functions round a decimal floating point value to an integer value in decimal floating point format; any digits after the decimal point are discarded. The current rounding mode is used. |
The round_mode parameter must be a compile-time constant
expression. Use either of the following:
|
These functions return the arithmetic value of the first parameter, with the exponent adjusted to match the second parameter. They can temporarily override the current rounding mode and use the specified rounding mode. |
|
These functions compare the exponents of two parameters. If the exponents are the same, the functions return "true". |
These functions normally return <0, ==0 or >0 to indicate the relation. If either value is a NaN, they return "-2" (unordered). |
These functions compare two decimal floating-point values. Unlike a comparison using standard equality or relational operators, they also raise an Invalid Operation exception when either operand is either a quiet Nan or a signaling NaN. |
The functions __d64_to_long_long ( ) and __d128_to_long_long ( ) use the current decimal rounding mode, while a cast always rounds towards zero. The functions __d64_to_long_long_rounding ( ) and __d128_to_long_long_rounding ( ) can temporarily override the current rounding mode and use the specified rounding mode. The round_mode parameter must be a compile-time constant
expression. Use either of the following:
|
These functions convert a decimal floating point value to a 64-bit signed binary integer with rounding mode options. |
unsigned long __dfp_get_round_mode (void); |
This function gets the current decimal rounding mode from the z/Architecture® FPC register. |
void __dfp_set_round_mode (unsigned long round_mode); If the rounding mode is
changed within a function, it must be restored before the function
returns.
|
This function sets the specified decimal rounding mode in the z/Architecture FPC register, making it the current mode. |
PROTOTYPE and Notes | Description |
---|---|
|
These functions return "true" if the parameter is not positive or negative infinity, and is not a NaN. |
|
These functions return "true" if the parameter is positive or negative infinity. |
|
These functions return "true" if the parameter is in the normal range, not a subnormal, infinity or NaN. |
|
These functions return "true" if the parameter is positive or negative signaling NaN. |
|
These instructions return "true" if the parameter is negative, including negative zero, negative infinity and negative NaN. |
|
These functions return "true" if the parameter is a subnormal. |
|
These functions return "true" if the parameter is positive or negative zero. |
PROTOTYPE and Notes | Description |
---|---|
|
These functions return the negative of the absolute value of the parameter. |
Note: Also
see functions that transfer a
value from GPRs.
|
These functions transfer a value from an FPR or FPR pair to a GPR, GPR pair, or four GPRs. |
Note: Also
see functions that transfer a
value to GPRs.
|
These functions transfer a value from a GPR, GPR pair, or four GPRs to an FPR or FPR pair. |
The round_mode parameter must be a compile-time constant
expression. Use either of the following:
If
the input value is a signaling NaN, and:
|
These functions convert a value to a narrower format, with rounding control and invalid exception control that is unavailable when using a cast. |
__d64_to_signed_BCD produces 15 decimal digits followed by a decimal sign in a 64-bit result. __d128_to_signed_BCD produces 31 decimal digits followed by a decimal sign in a 128-bit result. Negative values will be given the sign 0xD. If CorF is false, positive values will be given the sign 0xC. If CorF is true, positive values will be given the sign 0xF. |
These functions convert the lower digits of the parameter to signed packed format. |
The signs 0xA, 0xC, 0xE, and 0xF will be treated as positive, and 0xB and 0xD as negative. __signed_BCD_to_d64 converts 15 decimal digits followed by a decimal sign in a 64-bit input. __signed_BCD_to_d128 converts 31 decimal digits followed by a decimal sign in a 128-bit input. |
These functions convert signed packed decimal to decimal floating point. |
__unsigned_BCD_to_d64 converts 16 decimal digits with no sign in a 64-bit input. __unsigned_BCD_to_d128 converts 32 decimal digits with no sign in a 128-bit input. |
These functions convert the lower digits of the parameter to unsigned packed format. |
The round_mode parameter must be a compile-time constant
expression. Use either of the following:
|
These functions round a value to fewer digits.
They can temporarily override the current rounding mode. For correct
rounding, the input value must have been calculated using ROUND_TO_PREPARE_FOR |
Notes:
|
These functions return the digits and sign of the first parameter with the biased exponent of the second parameter, with special values for infinity, quiet NaN, or signaling NaN. |
|
These functions return the parameter with the coefficient shifted to the left. The sign and exponent are unchanged. The shift count must be in the 0-to-63 range; otherwise the result is undefined. |
|
These functions return the parameter with the coefficient shifted to the right. The sign and exponent are unchanged. The shift count must be in the 0-to-63 range; otherwise the result is undefined. |
These functions:
|
These functions determine whether a parameter is in a defined data class or a set of data classes, by testing its exponent and sign. |
These functions:
|
These functions determine whether a parameter is in a defined data group or set of data groups, by testing its exponent, sign and first digit. |
|
These functions return the exponent of the parameter as an integer. |
Positive values will be given the sign 0xC if CorF is false or 0xF if it is true. Negative values will be given the sign 0xD. __d64_to_unsigned_BCD produces 16 decimal digits with no sign in a 64-bit result. __d128_to_unsigned_BCD produces
32 decimal digits with no sign in a 128-bit result.
Note: Any digits to the left of those are ignored.
To access the ignored digits, use the appropriate __d#_shift_right function.
|
These functions convert the lower digits of the parameter to unsigned packed format. |
If both exponents are finite, these return "<0", "==0" or ">0" to indicate the relation between the exponents. If both exponents are infinite, they return "0". If one exponent is infinite and the other is finite, they return "-2" (unordered). |
These functions compare exponents to one another. |
|
These functions normally return the number of
significant digits in the input value. Exceptions:
|
|
This function modifies the Floating Point Control (FCP) register, and could raise an exception. |
PROTOTYPE and Notes | Description |
---|---|
The source points to the memory location that contains data in valid zoned format. The length specifies the length of the source field encoded in the machine instruction. The range of the length value can be "0-15" for __cdzt and "0-33" for __cxzt. When the length value is not a literal, an EX instruction is generated to execute a target CDZT or CXZT instruction. The mask value provides the M3 value encoded in the machine instruction. The mask value must be provided as a literal. The return value is the converted decimal floating-point value. |
These functions convert zoned type to decimal floating-point type. |
The source contains the decimal floating-point value to be converted. The result points to the memory location that receives the converted data in zoned format. The length specifies the number of rightmost digits of the decimal floating-point value to be converted. The length value specifies the length of the result field encoded in the machine instruction in bytes. The range of the length value can can be "0-15" for __czdt and "0-33" for __czxt. When the length value is not a literal, an EX instruction is generated to execute a target CZDT or CZXT instruction. The mask value provides the M3 value encoded in the machine instruction. The mask value must be provided as a literal. The return value is the condition code set by the instruction. |
These functions convert decimal floating-point type to zoned type. |