Exemple #1
0
        public static bool TryParse(string value, out IbDouble result)
        {
            int dotIndex = value.IndexOf('.');

            if (dotIndex < 0)
            {
                BigInteger sig;
                if (BigInteger.TryParse(value, out sig))
                {
                    result = (new IbDouble(sig, 0)).Normalize();
                    return(true);
                }
                else
                {
                    result = Zero;
                    return(false);
                }
            }
            else
            {
                var exp = value.Length - dotIndex - 1;
                value = value.Substring(0, dotIndex) + value.Substring(dotIndex + 1);
                BigInteger sig;
                if (BigInteger.TryParse(value, out sig))
                {
                    result = (new IbDouble(sig, checked ((short)exp))).Normalize();
                    return(true);
                }
                else
                {
                    result = Zero;
                    return(false);
                }
            }
        }
Exemple #2
0
 public static int Compare(IbDouble left, IbDouble right)
 {
     return(left < right ? -1 : (left > right ? 1 : 0));
 }
Exemple #3
0
 public static IbDouble Min(IbDouble left, IbDouble right)
 {
     return(left < right ? left : right);
 }
Exemple #4
0
 public static IbDouble Max(IbDouble left, IbDouble right)
 {
     return(left > right ? left : right);
 }
Exemple #5
0
 public static IbDouble Divide(IbDouble dividend, IbDouble divisor)
 {
     return(dividend / divisor);
 }
Exemple #6
0
 public static IbDouble Multiply(IbDouble left, IbDouble right)
 {
     return(left * right);
 }
Exemple #7
0
 public static IbDouble Subtract(IbDouble left, IbDouble right)
 {
     return(left - right);
 }
Exemple #8
0
 public static IbDouble Add(IbDouble left, IbDouble right)
 {
     return(left + right);
 }
Exemple #9
0
 public static IbDouble Negate(IbDouble value)
 {
     return(-value);
 }
Exemple #10
0
 public static IbDouble Abs(IbDouble value)
 {
     return(new IbDouble(value._sig < 0 ? value._sig : value._sig, value._exp));
 }