Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement