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