Created
October 18, 2018 12:34
-
-
Save noname007/bf25c7f053d164a833ddfd881741d4e0 to your computer and use it in GitHub Desktop.
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 | |
int main() { | |
double a = 0.58, *aptr = &a; | |
float af = 0.58, *afptr = ⁡ | |
printf(“%lu,%lx\n”,sizeof(a), *(long int *)aptr); | |
printf(“%lu,%x\n”,sizeof(af), *(int *)afptr); | |
// printf(“%lu,%d”,sizeof(a),(int) (a * 100) ); | |
// int b = 21; | |
// printf(“%lu, %p\n”, sizeof(b), b); | |
// printf(“%lu, %d\n”, sizeof(b), (int)(float) b); | |
return 0; | |
} |
问题:
- 浮点数能表示的最大数,(非正无穷) 是个整数,还是个浮点数
- printf 的输出
float c = (1 << 24); // 16777216.000000
float b = c - 1, d = c + 1, e = d + 1, f = e + 1; // 16777215.000000 16777216.000000 16777216.000000 16777216.000000 16777216.000000
printf("%f %f %f %f %f\n",b, c, d, e, f);
//float b = c - 1, d = c + 1, e = c + 2, f = c + 3;//16777215.000000 16777216.000000 16777216.000000 16777218.000000 16777220.000000
//printf("%f %f %f %f %f\n",b, c, d, e, f);
100.000100000000000332 == 100.000100000000000333 // true
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.