Skip to content

Instantly share code, notes, and snippets.

@benaryorg
Created July 3, 2019 14:03
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 benaryorg/41054af1a9f517fc43b23660661707fe to your computer and use it in GitHub Desktop.
Save benaryorg/41054af1a9f517fc43b23660661707fe to your computer and use it in GitHub Desktop.
#include <stdio.h>
union fi
{
unsigned i;
float f;
};
int main(void)
{
union fi fi = { .f = 16777000.0 };
while(((float)(fi.f += 1.0)) != ((float)(fi.f+1.0)))
{
printf("%.1f (%u) + 1.0 = %.1f (%.1lf)\n",fi.f,fi.i,(float) (fi.f+1.0),((double) fi.f)+1.0);
}
printf("%.1f (%u) + 1.0 = %.1f (%.1lf)\n",fi.f,fi.i,(float) (fi.f+1.0),((double) fi.f)+1.0);
fi.i++;
printf("%.1f (%u) + 1.0 = %.1f (%.1lf)\n",fi.f,fi.i,(float) (fi.f+1.0),((double) fi.f)+1.0);
printf("16777216.0f %c= 16777217.0f\n",(16777216.0f == 16777217.0f) ? '=' : '!');
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment