Set or get the current rounding
#include <fpstatus.h> int fp_rounding( int newrounding );
libm
The fp_rounding() function sets or gets the current rounding mode, depending on the value of newrounding:
If newrounding is less than 0, the current rounding mode; otherwise, the previous mode.
#include <fpstatus.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv)
{
int ret;
ret = fp_rounding(-1);
printf("Rounding mode: ");
if (ret == _FP_ROUND_NEAREST)
printf("Nearest \n");
else if (ret == _FP_ROUND_POSITIVE)
printf("Positive \n");
else if (ret == _FP_ROUND_NEGATIVE)
printf("Negative \n");
else if (ret == _FP_ROUND_ZERO)
printf("To Zero \n");
else
printf("Error \n");
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
fp_exception_mask(), fp_exception_value(), fp_precision()