Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <errno.h>
- #include <fenv.h>
- #pragma STDC FENV_ACCESS ON
- int main(void)
- {
- double pi = acos(-1);
- // typical usage
- printf("cos(pi/3) = %fn", cos(pi/3));
- printf("cos(pi/2) = %fn", cos(pi/2));
- printf("cos(-3*pi/4) = %fn", cos(-3*pi/4));
- // special values
- printf("cos(+0) = %fn", cos(0.0));
- printf("cos(-0) = %fn", cos(-0.0));
- // error handling
- feclearexcept(FE_ALL_EXCEPT);
- printf("cos(INFINITY) = %fn", cos(INFINITY));
- if(fetestexcept(FE_INVALID)) puts(" FE_INVALID raised");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement