コード例 #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);
                }
            }
        }
コード例 #2
0
 public static int Compare(IbDouble left, IbDouble right)
 {
     return(left < right ? -1 : (left > right ? 1 : 0));
 }
コード例 #3
0
 public static IbDouble Min(IbDouble left, IbDouble right)
 {
     return(left < right ? left : right);
 }
コード例 #4
0
 public static IbDouble Max(IbDouble left, IbDouble right)
 {
     return(left > right ? left : right);
 }
コード例 #5
0
 public static IbDouble Divide(IbDouble dividend, IbDouble divisor)
 {
     return(dividend / divisor);
 }
コード例 #6
0
 public static IbDouble Multiply(IbDouble left, IbDouble right)
 {
     return(left * right);
 }
コード例 #7
0
 public static IbDouble Subtract(IbDouble left, IbDouble right)
 {
     return(left - right);
 }
コード例 #8
0
 public static IbDouble Add(IbDouble left, IbDouble right)
 {
     return(left + right);
 }
コード例 #9
0
 public static IbDouble Negate(IbDouble value)
 {
     return(-value);
 }
コード例 #10
0
 public static IbDouble Abs(IbDouble value)
 {
     return(new IbDouble(value._sig < 0 ? value._sig : value._sig, value._exp));
 }