Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
#define __STDC_WANT_DEC_FP__
#include <fenv.h>
int fe_dec_getround(void);
The fe_dec_getround function gets the current rounding mode for decimal floating-point operations.
The following rounding modes are defined for decimal floating-point, and are located in fenv.h:
If successful, returns the value of the current rounding mode for decimal floating-point operations.
If there is no such rounding mode or the current rounding mode can't be determined returns -1.
⁄* CELEBF77
sample program that issues fe_dec_getround()⁄setround()
This program calls fe_dec_getround() to get the DFP rounding mode.
Then it will compare the returned value with FE_DEC_TONEAREST
rounding mode. If not the same, it will call fe_dec_setround() to
set the rounding mode to the desired value FE_DEC_TONEAREST.
*⁄
#define __STDC_WANT_DEC_FP__
#include <fenv.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]){
int r;
if ((r = fe_dec_getround()) == -1){
perror("fe_dec_getround");
exit (-1);
}
printf("The Decimal floating point rounding mode is %d\n", r);
if (r != FE_DEC_TONEAREST){
printf("The DFP rounding mode is not FE_DEC_TONEAREST.\n");
if (fe_dec_setround(FE_DEC_TONEAREST) == -1){
perror("fe_dec_setround");
exit (-1);
}
}
printf("The DFP rounding mode has been set to FE_DEC_TONEAREST.\n");
return 0;
}