B
Barry
What is the best way to round a double and store it in an int (C#)?
I'm currently using
intVar = (int)Math.Round(doubleVar);
I'm worried that the return value of e.g. Math.Round(2.1) might be
1.99999999999999999999999 (due to quirks of binary/decimal conversion),
and (int) will then truncate it to 2.
I'm currently using
intVar = (int)Math.Round(doubleVar);
I'm worried that the return value of e.g. Math.Round(2.1) might be
1.99999999999999999999999 (due to quirks of binary/decimal conversion),
and (int) will then truncate it to 2.