SHARE
TWEET

Untitled

a guest Jun 15th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <errno.h>
  4. #include <fenv.h>
  5.  
  6. #pragma STDC FENV_ACCESS ON
  7. int main(void)
  8. {
  9.     double pi = acos(-1);
  10.     // typical usage
  11.     printf("cos(pi/3) = %fn", cos(pi/3));
  12.     printf("cos(pi/2) = %fn", cos(pi/2));
  13.     printf("cos(-3*pi/4) = %fn", cos(-3*pi/4));
  14.     // special values
  15.     printf("cos(+0) = %fn", cos(0.0));
  16.     printf("cos(-0) = %fn", cos(-0.0));
  17.     // error handling
  18.     feclearexcept(FE_ALL_EXCEPT);
  19.     printf("cos(INFINITY) = %fn", cos(INFINITY));
  20.     if(fetestexcept(FE_INVALID)) puts("    FE_INVALID raised");
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top