Perhaps I have spent one too many nights up late, but I had the following code :
MessageBox.Show(
Convert.ToInt32(
Math.Round(
(double)( ( i+1 )/r.Count )*100 ,
0
)
).ToString()
);
Which always returns 0, even when i=120000
and r.Count=150000
. This is a simple progress calculation where i
is the current iteration in the loop, and r
is the collection ( List() ).
I have separated the code, and even the following still returns 0 :
Convert.ToInt32(
Math.Round(
(double)(( 120000+1 )/167428 )*100
, 0 )
)
Not sure whats going on here so any insight as to what I am doing wrong (probably a forehead slapper). It should be (using above numbers), returning 71.
@Habib's flag as duplicate :
that duplicate you claim -- is actually different, even the solutions don't apply here as this was a casting issue to double, and not adding 'm' with additional decimal points to each variable in play.