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