Visual C++ appears to double round floating-point literals when assigned to floats, even when the literals have the 'f' suffix attached. This can lead to double rounding errors, and as a result, incorrect decimal to floating-point conversions.For example, the decimal value 0.5000000894069671353303618843710864894092082977294921875 is 0.1000000000000000000000010111111111111111111111111111111 in binary. The part after bit 24 is 0111111111111111111111111111111, and so as a float, it should be rounded down to 0.100000000000000000000001. Visual C++ rounds it up to 0.10000000000000000000001, so the conversion is too high by 1 ULP.It appears double rounding is the culprit, since as a double, the decimal value above is rounded to 0.1000000000000000000000011. This has bit 25 = 1, and due to "round half even", it is rounded up to 0.10000000000000000000001 when going to single-precision.For the record, gcc on Linux does not have this problem.For a more detailed description of this problem, see my article http://www.exploringbinary.com/double-rounding-errors-in-floating-point-conversions/
Visual Studio/Silverlight/Tooling version
What category (if any) best represents this feedback?
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results