Trying to port java code to C++ I\'ve stumbled over some weird behaviour. I can\'t get double addition to work (even though compiler option /fp:strict which means \"correct\
Yes, it's certainly truncating to floats. I get the same value printing float f = 0.4
as you do in the "inaccurate" case. Try:
double b = 0.0 + (double) 0.4;
The question then is why it's truncating to floats. There's no excuse in the standard for treating 0.0 + 0.4
as a single-precision expression, since floating point literals are double-precision unless they have a suffix to say otherwise.
So something must be interfering with your settings, but I have no idea what.