/** * Initializes a new instance of the SqlMoney instance using the supplied Decimal value. * @param value The Decimal value to be stored as a SqlMoney instance. */ public SqlMoney(Decimal value) { if ((value.CompareTo(MaxValue.Value) > 0 || value.CompareTo(MinValue.Value) < 0)) throw new OverflowException("overflow - the value is out of range " + value); _value = value; _isNull = false; }
public virtual void encodeBigDecimal(Decimal bd) { int scale; Decimal temp; ConvertToScaledDecimal(bd, out scale, out temp); if (temp.CompareTo(long.MinValue) > 0 && temp.CompareTo(long.MaxValue) < 0) encodeLong((long)temp, scale); else { BigInteger bi = new BigInteger(Decimal.Truncate(Math.Abs(temp)).ToString(), 10); byte[] byteArray = bi.ToByteArray(); write(edsScaledCount2); write(scale); write(bd.CompareTo(Decimal.Zero)); write(byteArray.Length); write(byteArray); } }
/** * Initializes a new instance of the SqlMoney instance using the supplied double value. * @param value The double value to be stored as a SqlMoney instance. */ public SqlMoney(double value) { _value = new Decimal(value); if (_value.CompareTo(MaxValue.Value) > 0 || _value.CompareTo(MinValue.Value) < 0) throw new OverflowException("overflow - the value is out of range " + value); _isNull = false; }
/// <summary> /// Validates the frequency. Throws an <see cref="ArgumentOutOfRangeException"/> /// if the frequency is not in range. /// </summary> /// <param name="freq"> /// The frequency to validate. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="freq"/> must be between 40Hz and 1000Hz. /// </exception> private void ValidateFrequency(Decimal freq) { if ((freq.CompareTo(MIN_FREQUENCY) == -1) || (freq.CompareTo(MAX_FREQUENCY) == 1)) { throw new ArgumentOutOfRangeException("Frequency [" + freq.ToString() + "] must be between 40.0 and 1000.0 Hz."); } }
public static bool IsBetween(this Decimal @this, Decimal minValue, Decimal maxValue) { return(minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1); }
/// <summary> /// A T extension method that check if the value is between (exclusif) the minValue and maxValue. /// </summary> /// <param name="this">The @this to act on.</param> /// <param name="minValue">The minimum value.</param> /// <param name="maxValue">The maximum value.</param> /// <returns>true if the value is between the minValue and maxValue, otherwise false.</returns> /// ### /// <typeparam name="T">Generic type parameter.</typeparam> public static bool Between(this Decimal @this, Decimal minValue, Decimal maxValue) { return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1; }