/// <summary> /// Tries to convert the given Doudec to a Fraction. One way for this to fail is if the Doudec is infinite. /// </summary> public static bool TryToFraction(Doudec d, out Fraction result) { try { result = Fraction.FromDoudec(d); return(true); } catch (Exception) { result = default; return(false); } }
/// <summary> /// Tries to convert the given Doudec to a BigInteger. One way for this to fail is if the Doudec is infinite. /// </summary> public static bool TryToBigInteger(Doudec d, out BigInteger result) { if (Doudec.IsFinite(d)) { try { result = (BigInteger)d; return(true); } catch (Exception) { result = default; return(false); } } else { result = default; return(false); } }
public IntFloat(Doudec value) { this.value = value; floatNotInt = true; }
public bool Equals(Doudec dd) => intFloatNotFraction?ifloat.Equals(dd) : frac.Equals(dd);
public int CompareTo(Doudec dd) => intFloatNotFraction?ifloat.CompareTo(dd) : frac.ToDoudec().CompareTo(dd);