예제 #1
0
        public int CompareTo(Rational other)
        {
            var sign = Sign.CompareTo(other.Sign);

            if (sign != 0)
            {
                return(sign);
            }

            if ((IsNaN && other.IsNaN) || (IsInfinity && other.IsInfinity))
            {
                return(0);
            }
            if (IsNaN || other.IsNaN)
            {
                return(Denominator.CompareTo(other.Denominator));
            }
            if (IsPositiveInfinity || other.IsNegativeInfinity)
            {
                return(1);
            }
            if (IsNegativeInfinity || other.IsPositiveInfinity)
            {
                return(-1);
            }

            var diff = this - other;

            return(diff.Sign);
        }
예제 #2
0
        public int CompareTo(SingleLabel other)
        {
            if (other == null)
            {
                return(1);
            }

            int result = Sign.CompareTo(other.Sign);

            if (result != 0)
            {
                return(result);
            }

            return(SignIndex.CompareTo(other.SignIndex));
        }
예제 #3
0
        public override int CompareTo(Expr other)
        {
            var pCmp = base.CompareTo(other);

            if (other is TermNumericalExpr e)
            {
                if (pCmp == 0)
                {
                    pCmp = Sign.CompareTo(e.Sign);

                    if (pCmp == 0)
                    {
                        pCmp = Exprs.SetCompareTo(e.Exprs);
                    }
                }
            }

            return(pCmp);
        }
예제 #4
0
파일: ZNAK.cs 프로젝트: Roickard/Homework
        public int CompareTo(object obj)
        {
            ZNAK znak = obj as ZNAK;

            return(Sign.CompareTo(znak.Sign));
        }