A few days ago to do data processing when found a part of the value 0, screening and found with (int) after the integer part number is wrong, then do the following test
#include
Int main ()
{
Int I, res4 res5;
Float td1, fd1 and res1 and res2, res3;
Td1=1.0/10;
Fd1=1.0/1024;
I=274645;
Res1=I * td1/fd1;
Res2=(int) (res1) + 1;
Res3=(int) (res1 + 1);
Res4=(int) (res1) + 1;
Res5=(int) (res1 + 1);
Printf (" % f % f % f, % d % d \ n ", res1 and res2, res3 and res4, res5);
return 0;
}
The output 28123649 28123648
28123648.000000 28123648.000000 28123648.000000
This is very strange, one of the multiple + 1 under the data type conversion as failed, can't understand why,
Editor VS Code, the compiler GCC 8.1.0