public static SqlDecimal Ceiling(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 positive, adjust by adding 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;
}