[Previous] [Contents] [Next]

fp_exception_mask()

Return the current exception mask

Synopsis:

#include <fpstatus.h>

int fp_exception_mask ( int new_mask,
                        int set );

Library:

libm

Description:

The fp_exception_mask() function returns the current exception mask if set < 0. If set = 1, it enables the exception mask defined by new_mask, and if set = 0, it disables the exception mask defined by new_mask.

If Then
set Enable interrupts defined by new_mask.
!set Disable interrupts defined by new_mask.

Returns:

If set < 0
The current exception mask.
If set >= 0
The value of the previous mask.

Examples:

#include <fpstatus.h>

int main(int argc, char** argv) 
{
   int ret;

   if ((ret = fp_exception_mask(0, -1)) < 0)
      printf("*** Problem retrieving exceptions \n");
   printf("Exceptions Enabled: \n\t");
   if (ret & _FP_EXC_INEXACT)
      printf("Inexact ");
   if (ret & _FP_EXC_DIVZERO)
      printf("DivZero ");
   if (ret & _FP_EXC_UNDERFLOW)
      printf("Underflow ");
   if (ret & _FP_EXC_OVERFLOW)
      printf("Overflow ");
   if (ret & _FP_EXC_INVALID)
      printf("Invalid ");
   printf("\n");


   /* Set the exception mask to enable division by zero errors */
   if ((ret = fp_exception_mask(_FP_EXC_DIVZERO, 1)) < 0)
      printf("*** Problem setting exceptions \n");
   if ((ret = fp_exception_mask(0, -1)) < 0)
      printf("*** Problem retrieving exceptions \n");
   printf("Exceptions Enabled: \n\t");
   if (ret & _FP_EXC_INEXACT)
      printf("Inexact ");
   if (ret & _FP_EXC_DIVZERO)
      printf("DivZero ");
   if (ret & _FP_EXC_UNDERFLOW)
      printf("Underflow ");
   if (ret & _FP_EXC_OVERFLOW)
      printf("Overflow ");
   if (ret & _FP_EXC_INVALID)
      printf("Invalid ");
   printf("\n");

   return(0);
}

Classification:

ANSI

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

fp_exception_value(), fp_precision(), fp_rounding()


[Previous] [Contents] [Next]