コード例 #1
0
        /// <summary>
        /// Performs banker's rounding on the specified argument.
        /// </summary>
        /// <param name="value">The value to round.</param>
        /// <returns>Result of rounding.</returns>
        public static SqlExpression BankersRound(SqlExpression value)
        {
            var mainPart  = 2 * SqlDml.Floor((value + 0.5) / 2);
            var extraPart = SqlDml.Case();

            extraPart.Add(value - mainPart > 0.5, 1);
            extraPart.Else = 0;
            return(mainPart + extraPart);
        }
コード例 #2
0
 public static SqlExpression MathFloorDouble(
     [Type(typeof(double))] SqlExpression d)
 {
     return(SqlDml.Floor(d));
 }
コード例 #3
0
 public static SqlExpression MathFloorDecimal(
     [Type(typeof(decimal))] SqlExpression d)
 {
     return(SqlDml.Floor(d));
 }
コード例 #4
0
 public static SqlExpression MathFloorDecimal(
     [Type(typeof(decimal))] SqlExpression d)
 {
     return(TryCastToDecimalPS(SqlDml.Floor(d), 28, 0));
 }