I have this tiny piece of code
double s = -2.6114289999999998;
double s7 = Math.Round(s, 7);
double s5 = Math.Round(s, 5);
double s6 = Math.Round(s, 6);
With Platform = Any CPU, I get
s7: -2.611429
s5: -2.61143
s6: -2.611429
With Platform = x64, I get
s7: -2.6114289999999998
s5: -2.61143
s6: -2.6114289999999998
Why? (Output copied from VS's Locals window)
The whole piece of code is:
private void btnAlign_Click(object sender, EventArgs e)
{
double s = -2.6114289999999998;
double s7 = Math.Round(s, 7);
double s5 = Math.Round(s, 5);
double s6 = Math.Round(s, 6);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…