The answer to this question is : “down”.
Let me explain : if you had to round 3.45 to 1 decimal place, most people would arive at the answer of 3.5. Micosoft, or at least Math.Round doesn't. It rounds DOWN to 3.4. the rest of the cases work the same in Math.Round as it does in the mind of an individual with average intelligence. (3.44 rounds to 3.4 and 3.46 rounds to 3.5)
The office line from the help file is :
“The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.”
So if you want the IEEE Standard for people of at least average intelligence, section 39, you can try this function I wrote to bypass this stupidity:
public
static decimal Round(decimal value,int digits)
{
if (digits < 0)
{
throw new ArgumentException("Must be > 0","digits");
}
long multiplier;
if (digits == 0)
{
multiplier = 1;
}
else
{
multiplier = Math.Pow(10,digits);
}
double work = (double)value * multiplier;
double work2 = work - Math.Floor(work);
if (work2 >= 0.5)
{
return (decimal)( (Math.Floor(work) + 1) / multiplier );
}
else
{
return (decimal)( Math.Floor(work) / multiplier );
}
}
All jokes aside, I think they should have provided a function that rounds up as well.