System.Data.SqlTypes.SqlDecimal.AdjustScale C# (CSharp) Method

AdjustScale() public static method

public static AdjustScale ( SqlDecimal n, int digits, bool fRound ) : SqlDecimal
n SqlDecimal
digits int
fRound bool
return SqlDecimal
        public static SqlDecimal AdjustScale(SqlDecimal n, int digits, bool fRound)
        {
            if (n.IsNull)
                return SqlDecimal.Null;

            SqlDecimal ret = n;
            ret.AdjustScale(digits, fRound);
            return ret;
        }

Same methods

SqlDecimal::AdjustScale ( int digits, bool fRound ) : void

Usage Example

Example #1
0
        public static SqlBoolean operator <=(SqlDecimal x, SqlDecimal y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            if (x.IsPositive != y.IsPositive)
            {
                return(new SqlBoolean(y.IsPositive));
            }

            if (x.Scale > y.Scale)
            {
                y = SqlDecimal.AdjustScale(y, x.Scale - y.Scale, true);
            }
            else if (y.Scale > x.Scale)
            {
                x = SqlDecimal.AdjustScale(x, y.Scale - x.Scale, true);
            }

            for (int i = 3; i >= 0; i -= 1)
            {
                if (x.Data[i] == 0 && y.Data[i] == 0)
                {
                    continue;
                }
                else
                {
                    return(new SqlBoolean(x.Data[i] <= y.Data[i]));
                }
            }
            return(new SqlBoolean(true));
        }
All Usage Examples Of System.Data.SqlTypes.SqlDecimal::AdjustScale