예제 #1
0
 /// <summary>
 /// Checks the sign of the AseDecimal value.
 /// </summary>
 /// <param name="value">The AseDecimal structure whose design is being checked.</param>
 /// <returns>Returns an integer 0 for null, 1 for positive, and -1 for a negative values respectively.</returns>
 public static int Sign(AseDecimal value)
 {
     return(value.IsNull
         ? 0
         : value.IsNegative
             ? -1
             : 1);
 }
예제 #2
0
 public static bool TryParse(string s, out AseDecimal result)
 {
     try
     {
         result = Parse(s);
         return(true);
     }
     catch
     {
         result = Zero;
         return(false);
     }
 }
예제 #3
0
        public static AseDecimal Round(AseDecimal n, int outputScale)
        {
            if (outputScale < 0)
            {
                throw new AseException("Invalid value.", 30037);
            }

            //handles cases where the number is 0 < x < 1
            if (n < PositiveOne && n > NegativeOne)
            {
                outputScale -= 1;
            }

            return(new AseDecimal(n.Backing.Round(n.Precision - n.Scale + outputScale)));
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the AseDecimal structure.
 /// </summary>
 /// <param name="aseDecimal">An AseDecimal structure to initialize the value of the new AseDecimal.</param>
 public AseDecimal(AseDecimal aseDecimal) : this(new BigDecimal(new BigInteger(aseDecimal.Backing.Mantissa.ToByteArray()), aseDecimal.Backing.Exponent))
 {
 }
예제 #5
0
 public static AseDecimal Floor(AseDecimal n)
 {
     return(new AseDecimal(n.Backing.Floor()));
 }
예제 #6
0
 /// <summary>
 /// Compares the value of this AseDecimal with the AseDecimal value.
 /// </summary>
 public int CompareTo(AseDecimal value)
 {
     return(Backing.CompareTo(value.Backing));
 }