Skip to content

Instantly share code, notes, and snippets.

@rntz
Created March 1, 2019 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rntz/5ecab401719f1a4154c9081c2d21c2c2 to your computer and use it in GitHub Desktop.
Save rntz/5ecab401719f1a4154c9081c2d21c2c2 to your computer and use it in GitHub Desktop.
floating point wat
#include <stdio.h>
#define MAGIC 99586915107664152904966939075856564224.0
int main() {
float x = MAGIC;
if (x == 1.0/(1.0/x)) printf("float division involutive.\n");
if (x != 1/(1/x)) printf("... but not with 1/(1/x).\n");
double y = MAGIC;
if (y == 1/(1/y)) printf("... but it is with doubles.\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment