Created
January 26, 2014 02:14
-
-
Save uhziel/8627168 to your computer and use it in GitHub Desktop.
double 转 float 精度的丢失
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
/* | |
* (gdb) print d | |
* $1 = 10.1 | |
* (gdb) print f | |
* $2 = 10.1000004 | |
*/ | |
#include <stdlib.h> | |
int main() { | |
double d = atof("10.1"); | |
float f = (float)d; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment