I've got a scenario in .net (4.6.1) where parsing a string representation of a 6dp floating point value produces different results in 32 and 64 bit mode.
[Fact]
public void ParseTest()
{
var numText = "51.580133";
double.Parse(numText)
.ToString("R")
.Should().Be(numText);
}
This test passes in 32 bit mode, but for 64 bit mode fails as the text generated is: "51.580132999999996"
I'd expect rounding issues like this with irrational numbers or numbers derived via an equation, but there is no ambiguity about the length and accuracy of the floating point here.
This is inside an older system so changing everything to decimal would take a significant effort.
Questions:
Update This works, and produces a different output to ToString("G6"):
[Fact]
public void ParseText()
{
var numText = "51.580133";
double.Parse(numText)
.ToString("G8")
.Should().Be(numText);
}
I found this interesting point from Microsoft which might explain the issue
In some cases, Double values formatted with the "R" standard numeric format string do not successfully round-trip if compiled using the /platform:x64 or /platform:anycpu switches and run on 64-bit systems.
To work around this problem, you can format Double values by using the "G17" standard numeric format string. The following example uses the "R" format string with a Double value that does not round-trip successfully, and also uses the "G17" format string to successfully round-trip the original value.
The comment and an example can be found here: https://msdn.microsoft.com/en-us/library/kfsatb94(v=vs.110).aspx