Example #1
0
        /// <summary>
        /// Mathematical integer division operator between this XSFloat and the
        /// supplied ResultSequence.
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence to perform an integer division with </param>
        /// <returns> A XSInteger consisting of the result of the mathematical integer
        ///         division. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence idiv(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override ResultSequence idiv(ResultSequence arg)
        {
            ResultSequence carg = convertResultSequence(arg);
            XSFloat        val  = (XSFloat)get_single_type(carg, typeof(XSFloat));

            if (this.nan() || val.nan())
            {
                throw DynamicError.numeric_overflow("Dividend or divisor is NaN");
            }

            if (this.infinite())
            {
                throw DynamicError.numeric_overflow("Dividend is infinite");
            }

            if (val.zero())
            {
                throw DynamicError.div_zero(null);
            }

            decimal result = (decimal)(
                (double)
                (float_value() / val.float_value())
                );

            return(ResultSequenceFactory.create_new(new XSInteger(new BigInteger(result))));
        }
Example #2
0
        /// <summary>
        /// Equality comparison between this number and the supplied representation. </summary>
        /// <param name="aa">
        ///            The datatype to compare with
        /// </param>
        /// <returns> True if the two representations are of the same number. False
        ///         otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean eq(AnyType aa, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override bool eq(AnyType aa, DynamicContext dynamicContext)
        {
            Item carg = convertArg(aa);

            if (!(carg is XSFloat))
            {
                DynamicError.throw_type_error();
            }

            XSFloat f = (XSFloat)carg;

            if (nan() && f.nan())
            {
                return(false);
            }

            float?thatvalue = new float?(f.float_value());
            float?thisvalue = new float?(float_value());

            return(thisvalue.Equals(thatvalue));
        }