Simple question:
Console.WriteLine("Double: " + 2.0151231E7);
Double: 20151231
Console.WriteLine("Single: " + 2.0151231E7F);
Single: 2.015123E+07
Why?
Background: I’m consuming a soap web-service where an element is declared:
<xsd:element name="VALUE_FROM" type="xsd:float" />
In the soap response it looks like this:
<VALUE_FROM>2.0151231E7</VALUE_FROM>
But I’m getting 20151230 instead of 20151231.
20151231 has 25 digits in binary. A
floatonly has 24 binary digits in the mantissa.So the last bit had to go.