mac, Xcode
一些无法得到理想结果的代码和实际输出样式
- no mistake
printf(“%f\n", sqrt(-10));
nan
- no mistake
printf("%f\n", 1.0/0.0);
inf
#include <stdio.h>
#include <math.h>
int main()
{
//no mistake
printf("%f\n", 0.0/0.0);
//no mistake, but warn
//int isn't corresponded with double
printf("%f\n", 0/0);
//division by zero is undefined
printf("%d\n", 0/0);
return 0;
}
nan
nan
73823
- Two warn that division by zero is undefined
printf("%d\n", 1/0);
printf("%d\n", 0/0);
1606416392
网友评论