示例#1
0
        public static LuryObject Sub(LuryObject self, LuryObject other)
        {
            if (other.LuryTypeName == FullName)
            {
                return(GetObject((BigInteger)self.Value - (BigInteger)other.Value));
            }

            if (other.LuryTypeName == LuryReal.FullName)
            {
                return(LuryReal.GetObject((double)(BigInteger)self.Value - (double)other.Value));
            }

            throw new ArgumentException();
        }
示例#2
0
        public static LuryObject Pow(LuryObject self, LuryObject other)
        {
            if (other.LuryTypeName == FullName)
            {
                var exponent = (BigInteger)other.Value;

                if (exponent > int.MaxValue || exponent < int.MinValue)
                {
                    return(LuryReal.GetObject(Math.Pow((double)(BigInteger)self.Value, (double)exponent)));
                }

                return(GetObject(BigInteger.Pow((BigInteger)self.Value, (int)exponent)));
            }

            if (other.LuryTypeName == LuryReal.FullName)
            {
                return(LuryReal.GetObject(Math.Pow((double)(BigInteger)self.Value, (double)other.Value)));
            }

            throw new ArgumentException();
        }