コード例 #1
0
 /// <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);
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
 public IntFloat(Doudec value)
 {
     this.value  = value;
     floatNotInt = true;
 }
コード例 #4
0
 public bool Equals(Doudec dd) => intFloatNotFraction?ifloat.Equals(dd) : frac.Equals(dd);
コード例 #5
0
 public int CompareTo(Doudec dd) => intFloatNotFraction?ifloat.CompareTo(dd) : frac.ToDoudec().CompareTo(dd);