Example #1
0
        public static double GetPrecision(int digits, params double[] values)
        {
            int num1 = int.MinValue;

            for (int index = 0; index < values.Length; ++index)
            {
                double val = Math.Abs(values[index]);
                if (val != 0.0)
                {
                    int num2 = DoubleHelper.Log10(val);
                    if (num2 > num1)
                    {
                        num1 = num2;
                    }
                }
            }
            if (num1 > int.MinValue)
            {
                return(DoubleHelper.Pow10(Math.Max(num1 - digits, -DoubleHelper.DoubleNegativePowers.Length + 1)));
            }
            return(0.0);
        }
Example #2
0
 public static double GetPrecision(params double[] values)
 {
     return(DoubleHelper.GetPrecision(12, values));
 }
Example #3
0
 public static bool LessWithPrecision(this double value1, double value2)
 {
     return(DoubleHelper.LessWithPrecision(value1, value2, 0.0001));
 }
Example #4
0
 public static bool GreaterOrEqualWithPrecision(this double value1, double value2)
 {
     return(DoubleHelper.GreaterOrEqualWithPrecision(value1, value2, 0.0001));
 }
Example #5
0
 public DoubleR10(double value)
 {
     if (value > 0.0)
     {
         long num1 = (long)value;
         if (value < 1E+18 && (double)num1 == value)
         {
             this.M = num1;
             this.E = 0;
         }
         else
         {
             if (value < 100000000000000.0)
             {
                 double num2 = value * 10000.0;
                 long   num3 = (long)num2;
                 if ((double)num3 == num2)
                 {
                     this.M = num3;
                     this.E = -4;
                     return;
                 }
             }
             if (value <= double.MaxValue)
             {
                 int    exp  = DoubleHelper.Log10(value) - 14;
                 double num2 = DoubleHelper.Pow10(exp);
                 this.M = (long)Math.Round(value / num2);
                 this.E = exp;
             }
             else
             {
                 this = DoubleR10.PositiveInfinity;
             }
         }
     }
     else if (value < 0.0)
     {
         long num1 = (long)value;
         if (value > -1E+18 && (double)num1 == value)
         {
             this.M = num1;
             this.E = 0;
         }
         else
         {
             if (value > -100000000000000.0)
             {
                 double num2 = value * 10000.0;
                 long   num3 = (long)num2;
                 if ((double)num3 == num2)
                 {
                     this.M = num3;
                     this.E = -4;
                     return;
                 }
             }
             if (value >= double.MinValue)
             {
                 int    exp  = DoubleHelper.Log10(-value) - 14;
                 double num2 = DoubleHelper.Pow10(exp);
                 this.M = (long)Math.Round(value / num2);
                 this.E = exp;
             }
             else
             {
                 this = DoubleR10.NegativeInfinity;
             }
         }
     }
     else if (value == 0.0)
     {
         this = DoubleR10.Zero;
     }
     else
     {
         this = DoubleR10.NaN;
     }
 }