我正在使用GCC编译一个添加浮点数,长整数,整数和字符的程序.当它运行时,结果很糟糕.以下程序意外打印值34032.101562.
使用Microsoft编译器重新编译可以得到正确的结果.
#include <stdio.h>
int main (void) {
const char val_c = 10;
const int val_i = 20;
const long val_l = 34000;
const float val_f = 2.1;
float result;
result = val_c + val_i + val_l + val_f;
printf("%f\n", result);
return 0;
}
Run Code Online (Sandbox Code Playgroud)