Created
October 10, 2016 05:25
-
-
Save cloudwu/b268f7362ec29790c0f92a0917fa0e69 to your computer and use it in GitHub Desktop.
float
This file contains hidden or 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> | |
int | |
main() { | |
double f = 1.0/3.0; | |
double f2; | |
char tmp[100]; | |
sprintf(tmp, "%lf", f); | |
sscanf(tmp, "%lf", &f2); | |
printf("f = %lf f2 = %lf , %d\n", f, f2, (f2 == f)); // should be 0 (false) | |
sprintf(tmp, "%la", f); | |
sscanf(tmp, "%la", &f2); | |
printf("f = %la f2 = %la , %d\n", f, f2, (f2 == f)); // should be 1 (true) | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment