public void GreaterThan() { SqlByte testByte10 = new SqlByte(10); SqlByte testByte10II = new SqlByte(10); SqlByte testByte110 = new SqlByte(110); Assert.False(SqlByte.GreaterThan(testByte10, testByte110).Value); Assert.True(SqlByte.GreaterThan(testByte110, testByte10).Value); Assert.False(SqlByte.GreaterThan(testByte10II, testByte10).Value); }
public void GreaterThan() { SqlByte TestByte10 = new SqlByte(10); SqlByte TestByte10II = new SqlByte(10); SqlByte TestByte110 = new SqlByte(110); Assert.True(!SqlByte.GreaterThan(TestByte10, TestByte110).Value); Assert.True(SqlByte.GreaterThan(TestByte110, TestByte10).Value); Assert.True(!SqlByte.GreaterThan(TestByte10II, TestByte10).Value); }
public void GreaterThan() { SqlByte TestByte10 = new SqlByte(10); SqlByte TestByte10II = new SqlByte(10); SqlByte TestByte110 = new SqlByte(110); Assert.IsTrue(!SqlByte.GreaterThan(TestByte10, TestByte110).Value, "GreaterThan method 1" + Error); Assert.IsTrue(SqlByte.GreaterThan(TestByte110, TestByte10).Value, "GreaterThan method 2" + Error); Assert.IsTrue(!SqlByte.GreaterThan(TestByte10II, TestByte10).Value, "GreaterThan method 3" + Error); }
public override object Aggregate(int[] records, AggregateType kind) { bool hasData = false; try { switch (kind) { case AggregateType.Sum: SqlInt64 sum = 0; foreach (int record in records) { if (IsNull(record)) { continue; } checked { sum += _values[record]; } hasData = true; } if (hasData) { return(sum); } return(_nullValue); case AggregateType.Mean: SqlInt64 meanSum = 0; int meanCount = 0; foreach (int record in records) { if (IsNull(record)) { continue; } checked { meanSum += _values[record].ToSqlInt64(); } meanCount++; hasData = true; } if (hasData) { SqlByte mean = 0; checked { mean = (meanSum / meanCount).ToSqlByte(); } return(mean); } return(_nullValue); case AggregateType.Var: case AggregateType.StDev: int count = 0; SqlDouble var = 0; SqlDouble prec = 0; SqlDouble dsum = 0; SqlDouble sqrsum = 0; foreach (int record in records) { if (IsNull(record)) { continue; } dsum += _values[record].ToSqlDouble(); sqrsum += _values[record].ToSqlDouble() * _values[record].ToSqlDouble(); count++; } if (count > 1) { var = count * sqrsum - (dsum * dsum); prec = var / (dsum * dsum); // we are dealing with the risk of a cancellation error // double is guaranteed only for 15 digits so a difference // with a result less than 1e-15 should be considered as zero if ((prec < 1e-15) || (var < 0)) { var = 0; } else { var = var / (count * (count - 1)); } if (kind == AggregateType.StDev) { return(Math.Sqrt(var.Value)); } return(var); } return(_nullValue); case AggregateType.Min: SqlByte min = SqlByte.MaxValue; for (int i = 0; i < records.Length; i++) { int record = records[i]; if (IsNull(record)) { continue; } if ((SqlByte.LessThan(_values[record], min)).IsTrue) { min = _values[record]; } hasData = true; } if (hasData) { return(min); } return(_nullValue); case AggregateType.Max: SqlByte max = SqlByte.MinValue; for (int i = 0; i < records.Length; i++) { int record = records[i]; if (IsNull(record)) { continue; } if ((SqlByte.GreaterThan(_values[record], max)).IsTrue) { max = _values[record]; } hasData = true; } if (hasData) { return(max); } return(_nullValue); case AggregateType.First: if (records.Length > 0) { return(_values[records[0]]); } return(null); // no data => null case AggregateType.Count: count = 0; for (int i = 0; i < records.Length; i++) { if (!IsNull(records[i])) { count++; } } return(count); } } catch (OverflowException) { throw ExprException.Overflow(typeof(SqlByte)); } throw ExceptionBuilder.AggregateException(kind, _dataType); }
public override object Aggregate(int[] records, AggregateType kind) { bool flag = false; try { int num; SqlDouble num2; SqlDouble num3; int num4; int num5; int num6; int num7; int num8; int num9; int num10; int num11; SqlByte minValue; int num13; SqlByte maxValue; SqlDouble num15; int num16; SqlInt64 num17; SqlInt64 num18; int[] numArray; SqlDouble num19; int num21; int[] numArray2; int num22; int[] numArray3; switch (kind) { case AggregateType.Sum: num18 = 0L; numArray3 = records; num10 = 0; goto Label_007D; case AggregateType.Mean: num17 = 0L; num16 = 0; numArray2 = records; num9 = 0; goto Label_00EF; case AggregateType.Min: maxValue = SqlByte.MaxValue; num6 = 0; goto Label_0313; case AggregateType.Max: minValue = SqlByte.MinValue; num5 = 0; goto Label_0392; case AggregateType.First: if (records.Length <= 0) { return(null); } return(this.values[records[0]]); case AggregateType.Count: num = 0; num4 = 0; goto Label_03F7; case AggregateType.Var: case AggregateType.StDev: num = 0; num2 = 0.0; num19 = 0.0; num3 = 0.0; num15 = 0.0; numArray = records; num8 = 0; goto Label_01E6; default: goto Label_041C; } Label_0044: num22 = numArray3[num10]; if (!this.IsNull(num22)) { num18 += this.values[num22]; flag = true; } num10++; Label_007D: if (num10 < numArray3.Length) { goto Label_0044; } if (flag) { return(num18); } return(base.NullValue); Label_00B5: num21 = numArray2[num9]; if (!this.IsNull(num21)) { num17 += this.values[num21].ToSqlInt64(); num16++; flag = true; } num9++; Label_00EF: if (num9 < numArray2.Length) { goto Label_00B5; } if (flag) { SqlInt64 num23 = num17 / ((long)num16); return(num23.ToSqlByte()); } return(base.NullValue); Label_017E: num7 = numArray[num8]; if (!this.IsNull(num7)) { num3 += this.values[num7].ToSqlDouble(); num15 += this.values[num7].ToSqlDouble() * this.values[num7].ToSqlDouble(); num++; } num8++; Label_01E6: if (num8 < numArray.Length) { goto Label_017E; } if (num <= 1) { return(base.NullValue); } num2 = ((SqlDouble)(num * num15)) - (num3 * num3); num19 = num2 / (num3 * num3); bool x = num19 < 1E-15; if (!SqlBoolean.op_True(x)) { } if (SqlBoolean.op_True(x | (num2 < 0.0))) { num2 = 0.0; } else { num2 /= (double)(num * (num - 1)); } if (kind == AggregateType.StDev) { return(Math.Sqrt(num2.Value)); } return(num2); Label_02C3: num13 = records[num6]; if (!this.IsNull(num13)) { if (SqlByte.LessThan(this.values[num13], maxValue).IsTrue) { maxValue = this.values[num13]; } flag = true; } num6++; Label_0313: if (num6 < records.Length) { goto Label_02C3; } if (flag) { return(maxValue); } return(base.NullValue); Label_0342: num11 = records[num5]; if (!this.IsNull(num11)) { if (SqlByte.GreaterThan(this.values[num11], minValue).IsTrue) { minValue = this.values[num11]; } flag = true; } num5++; Label_0392: if (num5 < records.Length) { goto Label_0342; } if (flag) { return(minValue); } return(base.NullValue); Label_03E1: if (!this.IsNull(records[num4])) { num++; } num4++; Label_03F7: if (num4 < records.Length) { goto Label_03E1; } return(num); } catch (OverflowException) { throw ExprException.Overflow(typeof(SqlByte)); } Label_041C: throw ExceptionBuilder.AggregateException(kind, base.DataType); }