public static SqlDecimal Floor(SqlDecimal n)
{
n.AssertValid();
if (n.IsNull)
return SqlDecimal.Null;
if (n._bScale == 0)
return n;
bool fFraction; //Fractional flag
n.MakeInteger(out fFraction);
//When the numeric has fraction and is negative, subtract 1 by calling AddULong(1)
//Otherwise return the integral part.
if (fFraction && !n.IsPositive)
{
n.AddULong(1);
}
if (n.FZero())//if result is zero, sign should be positive
n.SetPositive();
n.AssertValid();
return n;
}