C
cody
the documentation states that Math.Round supports banker's rounding but it
also states that if the last number is 5 it will rounded up if the whole
number is even, otherwise rounded down which is totally bullshit!
i expect:
Round(1.344, 2) == 123.34
Round(1.345, 2) == 123.35
and nothing else!
for a workaround i had to write my own rounding method (not tested):
public static decimal Round(decimal val, int decimals)
{
decimal factor = (val * (decimal)Math.Pow(10, 2));
decimal tmp = Math.Floor(factor);
if (val - tmp >=0.5m)
tmp++;
return tmp/factor;
}
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no ****ing ads]
also states that if the last number is 5 it will rounded up if the whole
number is even, otherwise rounded down which is totally bullshit!
i expect:
Round(1.344, 2) == 123.34
Round(1.345, 2) == 123.35
and nothing else!
for a workaround i had to write my own rounding method (not tested):
public static decimal Round(decimal val, int decimals)
{
decimal factor = (val * (decimal)Math.Pow(10, 2));
decimal tmp = Math.Floor(factor);
if (val - tmp >=0.5m)
tmp++;
return tmp/factor;
}
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no ****ing ads]