Wednesday, 11 September 2013

Rounding up c# giving wrong answer

Rounding up c# giving wrong answer

I am programming a stocks/production program for a school project (bike
factory) and I have to round some numbers up such as the bikes that have
to be produced (due to fallout it are doubles).
If I use the following code:
double test = Math.Ceiling(100 * 1.09);
label75.Text = Convert.ToString(test);
I get as an answer 110, but that's not right, it should be 109 (9% of
100). Although it seems to work with values below 9%.
What am I doing wrong?

No comments:

Post a Comment