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