Esempio n. 1
0
        public static bool TryParse(string value, out IbFloat result)
        {
            int dotIndex = value.IndexOf('.');

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