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