예제 #1
0
파일: Variable.cs 프로젝트: prozum/cas.net
        public override string ToString()
        {
            string res;

            if (Prefix.CompareTo(Constant.MinusOne))
            {
                res = "-" + Identifier.ToString();
            }
            else if (!Prefix.CompareTo(Constant.One))
            {
                res = Prefix.ToString() + Identifier.ToString();
            }
            else
            {
                res = Identifier.ToString();
            }

            if (!Exponent.CompareTo(Constant.One))
            {
                res += "^" + Exponent.ToString();
            }

            return(res);
        }
예제 #2
0
파일: Variable.cs 프로젝트: prozum/cas.net
        public override bool CompareTo(Expression other)
        {
            var otherReduced = other.Reduce();

            if (otherReduced is Variable)
            {
                if (Identifier == (otherReduced as Variable).Identifier && Prefix.CompareTo((otherReduced as Variable).Prefix) && Exponent.CompareTo((otherReduced as Variable).Exponent))
                {
                    return(true);
                }

                if (IsDefined && (otherReduced as Variable).IsDefined)
                {
                    return(Value.CompareTo(otherReduced.Value));
                }
            }

            if (IsDefined)
            {
                return(otherReduced.CompareTo(Value));
            }

            return(false);
        }