So, I'm new to C++ and I have come across a weird behavior. This is my code
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float fValue = 123.12;
cout << fixed << "Value: " << fValue << endl;
return 0;
}
Now the output is kind of weird.
For different fValues the output is different e.g:
fValue: 123.12 Output: 123.120003
fValue: 1234.12 Output: 1234.119995
fValue: 1234.1231 Output: 1234.123047
So, not sure what I'm doing wrong here or what the problem is.