Ejemplo n.º 1
0
        private static int IndeterminantCompare(Indeterminates leftType, Fraction right)
        {
            switch (leftType)
            {
            case Indeterminates.NaN:   // NaN jest:
                if (right.IsNaN())     // równe NaN
                {
                    return(0);
                }
                if (right.IsNegativeInfinity())
                {
                    return(1);                    // większe niż -niekończoność
                }
                return(-1);                       // mniejsze niż cokolwiek innego

            case Indeterminates.NegativeInfinity: // -nieskończoność jest:
                if (right.IsNegativeInfinity())   // równe -nieskończoność
                {
                    return(0);
                }
                return(-1);                                 // mniejsze niż cokolwiek innego

            case Indeterminates.PositiveInfinity:           // nieskończoność jest:
                return(right.IsPositiveInfinity() ? 0 : 1); // równe nieskończoność lub większe niż cokolwiek innego

            default:                                        // nie powinno być osiągalne
                return(0);
            }
        }
Ejemplo n.º 2
0
        private static int IndeterminantCompare(Indeterminates leftType, Fraction right)
        {
            switch (leftType)
            {
            case Indeterminates.PositiveInfinity:
                return((right.IsPositiveInfinity()) ? 0 : 1);

            case Indeterminates.NegativeInfinity:
                return((right.IsNegativeInfinity()) ? 0 : -1);

            default:                     //Indeterminates.NaN
                return((right.IsNaN()) ? 0 : ((right.IsNegativeInfinity()) ? 1 : -1));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines how this Fraction, of an indeterminate type, compares to another Fraction
        /// </summary>
        /// <param name="leftType">What kind of indeterminate</param>
        /// <param name="right">The other Fraction to compare against</param>
        /// <returns>-1 if this is less than <paramref name="right"></paramref>,
        ///  0 if they are equal,
        ///  1 if this is greater than <paramref name="right"></paramref></returns>
        /// <remarks>NaN is less than anything except NaN and Negative Infinity. Negative Infinity is less
        /// than anything except Negative Infinity. Positive Infinity is greater than anything except
        /// Positive Infinity.</remarks>
        private static int IndeterminantCompare(Indeterminates leftType, Fraction right)
        {
            switch (leftType)
            {
            case Indeterminates.NaN:
                // A NaN is...
                if (right.IsNaN())
                {
                    return(0);      // equal to a NaN
                }
                else if (right.IsNegativeInfinity())
                {
                    return(1);      // great than Negative Infinity
                }
                else
                {
                    return(-1);     // less than anything else
                }

            case Indeterminates.NegativeInfinity:
                // Negative Infinity is...
                if (right.IsNegativeInfinity())
                {
                    return(0);      // equal to Negative Infinity
                }
                else
                {
                    return(-1);     // less than anything else
                }

            case Indeterminates.PositiveInfinity:
                if (right.IsPositiveInfinity())
                {
                    return(0);      // equal to Positive Infinity
                }
                else
                {
                    return(1);      // greater than anything else
                }

            default:
                // this CAN'T happen, something VERY wrong is going on...
                return(0);
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Private constructor to synthesize a Fraction for indeterminates (NaN and infinites)
		/// </summary>
		/// <param name="type">Kind of inderterminate</param>
		private Fraction(Indeterminates type)
		{
			m_Numerator = (long)type;
			m_Denominator = 0;
			// do NOT reduce, we're clean as can be!
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Determines how this Fraction, of an indeterminate type, compares to another Fraction
		/// </summary>
		/// <param name="leftType">What kind of indeterminate</param>
		/// <param name="right">The other Fraction to compare against</param>
		/// <returns>-1 if this is less than <paramref name="right"></paramref>,
		///  0 if they are equal,
		///  1 if this is greater than <paramref name="right"></paramref></returns>
		/// <remarks>NaN is less than anything except NaN and Negative Infinity. Negative Infinity is less
		/// than anything except Negative Infinity. Positive Infinity is greater than anything except
		/// Positive Infinity.</remarks>
		private static int IndeterminantCompare(Indeterminates leftType, Fraction right)
		{
			switch (leftType)
			{
				case Indeterminates.NaN:
					// A NaN is...
					if (right.IsNaN())
						return 0;	// equal to a NaN
					else if (right.IsNegativeInfinity())
						return 1;	// great than Negative Infinity
					else
						return -1;	// less than anything else

				case Indeterminates.NegativeInfinity:
					// Negative Infinity is...
					if (right.IsNegativeInfinity())
						return 0;	// equal to Negative Infinity
					else
						return -1;	// less than anything else

				case Indeterminates.PositiveInfinity:
					if (right.IsPositiveInfinity())
						return 0;	// equal to Positive Infinity
					else
						return 1;	// greater than anything else

				default:
					// this CAN'T happen, something VERY wrong is going on...
					return 0;
			}
		}
Ejemplo n.º 6
0
 // Indeterminates constructor
 private Fraction(Indeterminates type)
     : this()
 {
     Numerator   = (long)type;
     Denominator = 0;
 }
Ejemplo n.º 7
0
 private Fraction(Indeterminates type)
 {
     _numerator   = (long)type;
     _denominator = 0;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Private constructor to synthesize a Fraction for indeterminates (NaN and infinites)
 /// </summary>
 /// <param name="type">Kind of inderterminate</param>
 private Fraction(Indeterminates type)
 {
     m_Numerator   = (long)type;
     m_Denominator = 0;
     // do NOT reduce, we're clean as can be!
 }