I did my research on floating point calculation and I understood how it is being stored and how inaccuracy comes but with the following case I think its a outlier . Can anyone please help why that it so .
Source Code -
int main()
{
float f = 3.9999999f;
printf("%f",f);
}
Output -
4.000000
[Question - Why 4.000000 I did calculation but i am getting around 3.099999976158142089844]
Can anyone please Help me with this .
Compiler spec-
Using built-in specs.
COLLECT_GCC=somepath\gcc.exe
Target: mingw32
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
Video I refereed to understand floating point calculation - https://www.youtube.com/watch?v=iV-K-gNDC5A