I am currently porting some codes from Windows to Linux (Ubuntu) from a MS VS2008 compiler to GCC.
The problem is that the following code has different results:
double d = 19.53125;
std::cout.precision(4);
std::cout.setf(std::ios::fixed);
std::cout << d << std::endl;
Windows output: 19.5313
Linux output: 19.5312
If I set the precision to 5 the output is the same.
I expect that 19.53125 will be rounded up to 19.5313.
Any suggestions how I can get the desired rounding behavior?
Note: Windows code runs native on Windows 10 laptop and the Linux code runs inside a 64-bit Ubuntu 18.04 LTS VM.