예제 #1
0
        public NumericValue Exp(NumericValue exponentVal)
        {
            exponentVal.VerifyNoUnits("Exponent cannot have units.");

            if (!exponentVal.IsInteger)
            {
                VerifyNoUnits("Base can only have units for positive integer exponents.");
                return(new NumericValue(Math.Pow(GetFloat, exponentVal.GetFloat)));
            }

            var    exponent = exponentVal.IntValue;
            object result;

            if ((exponent >= 0) && (IsInteger))
            {
                result = BigInteger.Pow(GetInteger, exponent);
            }
            else
            {
                result = Math.Pow(GetFloat, exponent);
            }
            return(new NumericValue(result, Units ^ exponent));
        }
예제 #2
0
 public static NumericValue Atan2(NumericValue xOfs, NumericValue yOfs)
 {
     xOfs.VerifyNoUnits();
     yOfs.VerifyNoUnits();
     return(new NumericValue(Math.Atan2(xOfs.GetFloat, yOfs.GetFloat), "rad"));
 }
예제 #3
0
 public NumericValue ShiftRight(NumericValue val2)
 {
     val2.VerifyNoUnits();
     return(new NumericValue(GetInteger >> val2.IntValue, Units));
 }