Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fenv.h>
- #include <math.h>
- #include <stdio.h>
- int main(void)
- {
- fesetround(FE_UPWARD);
- float smallest = nextafterf(0.f, 1.f);
- float cur, prev;
- for(cur = prev = smallest; cur < HUGE_VALF;
- prev = cur, cur = nextafterf(cur, HUGE_VALF)) {
- if(cur - smallest + smallest > cur)
- printf("Failed %1$g - %2$g + %2$g <= %1$g\n", cur, smallest);
- if(cur - prev + prev > cur)
- printf("Failed %1$g - %2$g + %2$g <= %1$g\n", cur, prev);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement