Skip to content

Instantly share code, notes, and snippets.

@ridiculousfish
Created September 8, 2022 22:20
Show Gist options
  • Save ridiculousfish/bfa7ed6b1d76c114e19b379e1b9be16f to your computer and use it in GitHub Desktop.
Save ridiculousfish/bfa7ed6b1d76c114e19b379e1b9be16f to your computer and use it in GitHub Desktop.
#include <math.h>
#include <float.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
__attribute__((noinline))
double nafter(double x) {
return nextafter(x, INFINITY);
}
int main(void) {
double dbl = nafter(0.0);
int64_t i64 = 0;
memcpy(&i64, &dbl, sizeof i64);
printf("%lld\n", (long long)i64);
printf("positive: %d\n", dbl > 0.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment