lundi 5 janvier 2015

Why are these two mathematically equal decimals different? [duplicate]


This question already has an answer here:





[Test]
public void Calculation()
{
decimal a = 400m;
decimal b = 12m;
decimal c = 2m;
var result = a / b / c;

Assert.AreEqual(result, 400m / 24m);
}


Test Outcome: Failed

Result Message:

Expected: 16.666666666666666666666666666m

But was : 16.666666666666666666666666667m


Why are these two decimals different?

What can I use instead of 400m / 24m to make it equal to result?


Aucun commentaire:

Enregistrer un commentaire