Examples of round()


Examples of client.net.sf.saxon.ce.value.NumericValue.round()

            case FLOOR:
                return val.floor();
            case CEILING:
                return val.ceiling();
            case ROUND:
                 return val.round();
            case HALF_EVEN:
                int scale = 0;
                if (argument.length==2) {
                    AtomicValue scaleVal0 = (AtomicValue)argument[1].evaluateItem(context);
                    NumericValue scaleVal = (NumericValue)scaleVal0;
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper.round()

        int targetPrecision = targetInstance.attribute(DecimalAttribute.PRECISION);
        int inputScale = inputInstance.attribute(DecimalAttribute.SCALE);
        int targetScale = targetInstance.attribute(DecimalAttribute.SCALE);
        if ( (inputPrecision != targetPrecision) || (inputScale != targetScale) ) {
            BigDecimalWrapper bdw = new BigDecimalWrapperImpl().set(getWrapper(source, inputInstance));
            bdw.round(targetScale);
            target.putObject(bdw);
        }
        else if (source.hasCacheValue()) {
            target.putObject(source.getObject());
        }
View Full Code Here

Examples of java.math.BigDecimal.round()

        }

        BigDecimal res = value.multiply(val.value);
        if (res.precision() > digits) {
            // TODO: rounding mode should not be hard-coded. See #mode.
            res = res.round(new MathContext(digits,  RoundingMode.HALF_UP));
        }
        return new RubyBigDecimal(runtime, res).setResult();
    }
   
    @JRubyMethod(name = {"**", "power"}, required = 1)
View Full Code Here

Examples of java.math.BigDecimal.round()

        }

        for (int i = 0; i < values.size(); i++) {
            BigDecimal expected = values.get(i);
            BigDecimal actual = (BigDecimal)PDataType.DECIMAL.toObject(byteValues.get(i));
            assertTrue("For " + i + " expected " + expected + " but got " + actual,expected.round(PDataType.DEFAULT_MATH_CONTEXT).compareTo(actual.round(PDataType.DEFAULT_MATH_CONTEXT)) == 0);
            assertTrue(byteValues.get(i).length <= PDataType.DECIMAL.estimateByteSize(expected));
        }

        Collections.sort(values);
        Collections.sort(byteValues, Bytes.BYTES_COMPARATOR);
View Full Code Here

Examples of java.math.BigDecimal.round()

        for (int i = 0; i < values.size(); i++) {
            BigDecimal expected = values.get(i);
            byte[] bytes = PDataType.DECIMAL.toBytes(values.get(i));
            assertNotNull("bytes converted from values should not be null!", bytes);
            BigDecimal actual = (BigDecimal)PDataType.DECIMAL.toObject(byteValues.get(i));
            assertTrue("For " + i + " expected " + expected + " but got " + actual,expected.round(PDataType.DEFAULT_MATH_CONTEXT).compareTo(actual.round(PDataType.DEFAULT_MATH_CONTEXT))==0);
        }


        {
            String[] strs ={
View Full Code Here

Examples of java.math.BigDecimal.round()

         */
        double zerr = x.doubleValue() * x.ulp().doubleValue();
        MathContext mc = new MathContext(2 + err2prec(z.doubleValue(), zerr));

        /* Pull square root */
        z = sqrt(z.round(mc));

        /* Final rounding. Absolute error in the square root is x*xerr/z, where zerr holds 2*x*xerr.
         */
        mc = new MathContext(err2prec(z.doubleValue(), 0.5 * zerr / z.doubleValue()));
        return z.round(mc);
View Full Code Here

Examples of java.math.BigDecimal.round()

        z = sqrt(z.round(mc));

        /* Final rounding. Absolute error in the square root is x*xerr/z, where zerr holds 2*x*xerr.
         */
        mc = new MathContext(err2prec(z.doubleValue(), 0.5 * zerr / z.doubleValue()));
        return z.round(mc);
    } /* BigDecimalMath.hypot */


   

View Full Code Here

Examples of java.math.BigDecimal.round()

                    int pex = 1;
                    while (exsub-- > 0)
                        pex *= 10;
                    expxby10 = expxby10.pow(pex, mctmp);
                }
                return expxby10.round(mc);
            }
        }
    } /* BigDecimalMath.exp */

    /** The base of the natural logarithm.
View Full Code Here

Examples of java.math.BigDecimal.round()

            /* error propagation: log(x+errx) = log(x)+errx/x, so the absolute error
             * in the result equals the relative error in the input, xUlpDbl/xDbl .
             */
            MathContext mc = new MathContext(err2prec(resul.doubleValue(), xUlpDbl / xDbl));
            return resul.round(mc);
        }
    } /* BigDecimalMath.log */

    /** The natural logarithm.
     * @param x the argument.
View Full Code Here

Examples of java.math.BigDecimal.round()

             */
            MathContext mcloc = new MathContext(1 + err2prec(eps));

            final BigDecimal resul = log(r.BigDecimalValue(mcloc));

            return resul.round(mc);
        }
    } /* log */

    /** Power function.
     * @param x Base of the power.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.