Skip to content

Instantly share code, notes, and snippets.

@uhziel
Created January 26, 2014 02:14
Show Gist options
  • Save uhziel/8627168 to your computer and use it in GitHub Desktop.
Save uhziel/8627168 to your computer and use it in GitHub Desktop.
double 转 float 精度的丢失
/*
* (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