Created
March 1, 2016 09:46
-
-
Save mskashi/bd59f51d934d3c7ed42c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <float.h> | |
#include <stdint.h> | |
#include <inttypes.h> | |
int64_t d2i(double x) | |
{ | |
union { | |
int64_t i; | |
double d; | |
} tmp; | |
tmp.d = x; | |
if (tmp.i < 0) { | |
tmp.d = -x; | |
return -tmp.i; | |
} else { | |
return tmp.i; | |
} | |
} | |
int main() | |
{ | |
printf("%" PRId64 "\n", d2i(1 + DBL_EPSILON) - d2i(1.)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment