Skip to content

Instantly share code, notes, and snippets.

@Keruspe
Created October 18, 2011 17:20
Show Gist options
  • Save Keruspe/1296023 to your computer and use it in GitHub Desktop.
Save Keruspe/1296023 to your computer and use it in GitHub Desktop.
Would this be a bug in the glibc ?
#include <stdio.h>
int
main()
{
float f = 3.5;
int i = 8;
const char *format_previous = "%f";
printf ("This will output the previous float, expecting the good one\n");
printf (format_previous, f);
printf (" (expected %f)\n", f);
printf (format_previous, i);
printf (" (expected %f)\n", (float) i);
printf ("This will output the good float, expecting 0\n");
const char *format_0 = "%f (expected %f)\n";
printf (format_0, f, f);
printf (format_0, i, (float) i);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment