Exemple #1
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Returns the result of multiplying the specified Decimal value by negative one. 
 /// </summary>
 /// <param name="d">A DBDecimal.</param>
 /// <returns>A Decimal with the value of <c>d</c>, but the opposite sign.</returns>
 // --------------------------------------------------------------------------------
 public static DBDecimal Negate(DBDecimal d)
 {
     if (d.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Negate (d);
 }
Exemple #2
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Converts the value of a specified instance of DBDecimal to its equivalent 
 /// binary representation.
 /// </summary>
 /// <param name="d">A DBDecimal.</param>
 /// <returns>
 /// A 32-bit signed integer array with four elements that contain the binary 
 /// representation of <c>d</c>.
 /// </returns>
 /// <remarks>
 /// <para>
 /// The binary representation of a DBDecimal number consists of a 1-bit sign, a 
 /// 96-bit integer number, and a scaling factor used to divide the integer 
 /// number and specify what portion of it is a decimal fraction. The scaling 
 /// factor is implicitly the number 10, raised to an exponent ranging from 0 to 28.
 /// </para>
 /// <para>
 /// The return value is a four-element long array of 32-bit signed integers.
 /// </para>
 /// <para>
 /// The first, second, and third elements of the returned array contain the 
 /// low, middle, and high 32 bits of the 96-bit integer number.
 /// </para>
 /// <para>
 /// The fourth element of the returned array contains the scale factor and sign. 
 /// It consists of the following parts:
 /// </para>
 /// <para>
 /// Bits 0 to 15, the lower word, are unused and must be zero.
 /// </para>
 /// <para>
 /// Bits 16 to 23 must contain an exponent between 0 and 28, that indicates the 
 /// power of 10 to divide the integer number.
 /// </para>
 /// <para>
 /// Bits 24 to 30 are unused and must be zero.
 /// </para>
 /// <para>
 /// Bit 31 contains the sign; 0 meaning positive, and 1 meaning negative.
 /// </para>
 /// <para>
 /// Note that the bit representation differentiates between negative and 
 /// positive zero. These values are treated as being equal in all operations.
 /// </para>
 /// </remarks>
 /// <exception cref="InvalidOperationException">
 /// <c>d</c> has a Null value.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static int[] GetBits(DBDecimal d)
 {
     if (d.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.GetBits (d);
 }
Exemple #3
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Multiplies two specified DBDecimal values. 
 /// </summary>
 /// <param name="d1">A DBDecimal (the multiplicand).</param>
 /// <param name="d2">A DBDecimal (the multiplier). </param>
 /// <returns>
 /// A DBDecimal that is the result of multiplying <c>d1</c> and <c>d2</c>.
 /// </returns>
 /// <exception cref="OverflowException">
 /// The return value is less than <see cref="MinValue"/> or 
 /// greater than <see cref="MaxValue"/>.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Multiply(DBDecimal d1, DBDecimal d2)
 {
     if (d1.IsNull || d2.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Multiply (d1, d2);
 }
Exemple #4
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Returns a value indicating whether two specified instances of Decimal 
 /// represent the same value.
 /// </summary>
 /// <param name="d1">A DBDecimal.</param>
 /// <param name="d2">A DBDecimal.</param>
 /// <returns>true if <c>d1</c> and <c>d2</c> are equal; otherwise, false.</returns>
 // --------------------------------------------------------------------------------
 public static bool Equals(DBDecimal d1, DBDecimal d2)
 {
     if (d1.IsNull || d2.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Equals (d1, d2);
 }
Exemple #5
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Rounds a specified Decimal number to the closest integer toward 
 /// negative infinity.
 /// </summary>
 /// <param name="value">A DBDecimal.</param>
 /// <returns>
 /// If <c>d</c> has a fractional part, the next whole DBDecimal number toward 
 /// negative infinity that is less than <c>d</c>; or if <c>d</c> doesn't have a 
 /// fractional part, <c>d</c> is returned unchanged.
 /// </returns>
 /// <exception cref="InvalidOperationException">
 /// <c>d</c> has a Null value.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Floor(DBDecimal value)
 {
     if (value.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Floor (value);
 }
Exemple #6
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Divides two specified Decimal values.
 /// </summary>
 /// <param name="d1">A DBDecimal (the divident).</param>
 /// <param name="d2">A DBDecimal (the divisor).</param>
 /// <returns>
 /// The DBDecimal that is the result of dividing <c>d1</c> by <c>d2</c>.
 /// </returns>
 /// <exception cref="DivideByZeroException">
 /// <c>d2</c> is zero.
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// Either <c>d1</c> or <c>d2</c> has a Null value.
 /// </exception>
 /// <exception cref="OverflowException">
 /// The return value is less than <see cref="MinValue"/> or 
 /// greater than <see cref="MaxValue"/>.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Divide(DBDecimal d1, DBDecimal d2)
 {
     if (d1.IsNull || d2.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Divide (d1, d2);
 }
Exemple #7
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Converts the specified DBDecimal value to the equivalent OLE Automation 
 /// Currency value, which is contained in a 64-bit signed integer.
 /// </summary>
 /// <param name="value">A DBDecimal value.</param>
 /// <returns>A 64-bit signed integer that contains the OLE Automation equivalent 
 /// of <c>value</c>.</returns>
 // --------------------------------------------------------------------------------
 public static long ToOACurrency(DBDecimal value)
 {
     if (value.IsNull)
       {
     return 0;
       }
       return DBDecimal.ToOACurrency (value);
 }
Exemple #8
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Subtracts one specified DBDecimal value from another. 
 /// </summary>
 /// <param name="d1">A DBDecimal (the minuend).</param>
 /// <param name="d2">A DBDecimal (the subtrahend). </param>
 /// <returns>
 /// The DBDecimal result of subtracting <c>d2</c> from <c>d1</c>.
 /// </returns>
 /// <exception cref="InvalidOperationException">
 /// Either <c>d1</c> or <c>d2</c> has a Null value.
 /// </exception>
 /// <exception cref="OverflowException">
 /// The sum of <c>d1</c> and <c>d2</c> is less than <see cref="MinValue"/> or 
 /// greater than <see cref="MaxValue"/>.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Subtract(DBDecimal d1, DBDecimal d2)
 {
     if (d1.IsNull || d2.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Subtract (d1, d2);
 }
Exemple #9
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Rounds a DBDecimal value to a specified number of decimal places. 
 /// </summary>
 /// <param name="d">A DBDecimal value to round.</param>
 /// <param name="decimals">
 /// A value from 0 to 28 that specifies the number of decimal places to round to.
 /// </param>
 /// <returns>
 /// The DBDecimal number equivalent to d rounded to decimals number of decimal 
 /// places.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <c>decimals</c> is not a value from 0 to 28.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Round(DBDecimal d, int decimals)
 {
     if (d.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Round (d, decimals);
 }
Exemple #10
0
 // --------------------------------------------------------------------------------
 /// <summary>
 /// Computes the remainder after dividing two Decimal values. 
 /// </summary>
 /// <param name="d1">A DBDecimal (the divident).</param>
 /// <param name="d2">A DBDecimal (the divisor).</param>
 /// <returns>
 /// The DBDecimal that is the remainder of dividing <c>d1</c> by <c>d2</c>.
 /// </returns>
 /// <exception cref="DivideByZeroException">
 /// <c>d2</c> is zero.
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// Either <c>d1</c> or <c>d2</c> has a Null value.
 /// </exception>
 /// <exception cref="OverflowException">
 /// The return value is less than <see cref="MinValue"/> or 
 /// greater than <see cref="MaxValue"/>.
 /// </exception>
 // --------------------------------------------------------------------------------
 public static DBDecimal Remainder(DBDecimal d1, DBDecimal d2)
 {
     if (d1.IsNull || d2.IsNull)
       {
     throw new InvalidOperationException ();
       }
       return Decimal.Remainder (d1, d2);
 }