Package java.math

Examples of java.math.BigDecimal.divide()


            final BigDecimal MB = new BigDecimal(1000L * 1000);
            final BigDecimal GB = new BigDecimal(1000L * 1000 * 1000);

            BigDecimal bd = new BigDecimal(value);
            if (bd.compareTo(GB) > 0) {
                bd = bd.divide(GB);
                suffix = "GB";
            } else if (bd.compareTo(MB) > 0) {
                bd = bd.divide(MB);
                suffix = "MB";
            } else if (bd.compareTo(KB) > 0) {
View Full Code Here


            BigDecimal bd = new BigDecimal(value);
            if (bd.compareTo(GB) > 0) {
                bd = bd.divide(GB);
                suffix = "GB";
            } else if (bd.compareTo(MB) > 0) {
                bd = bd.divide(MB);
                suffix = "MB";
            } else if (bd.compareTo(KB) > 0) {
                bd = bd.divide(KB);
                suffix = "kB";
            } else {
View Full Code Here

                suffix = "GB";
            } else if (bd.compareTo(MB) > 0) {
                bd = bd.divide(MB);
                suffix = "MB";
            } else if (bd.compareTo(KB) > 0) {
                bd = bd.divide(KB);
                suffix = "kB";
            } else {
                suffix = "B";
            }
            suffixedValue = bd.setScale(2, RoundingMode.UP).toString();
View Full Code Here

     * @param context the MathContext.
     * @return the mean of the numbers.
     */
    public static BigDecimal mean(List<BigDecimal> numbers, MathContext context) {
        BigDecimal sum = sum(numbers);
        return sum.divide(new BigDecimal(numbers.size()), context);
    }

    /**
     * Returns the min number in the numbers list.
     *
 
View Full Code Here

        for (BigDecimal number : numbers) {
            BigDecimal XminMean = number.subtract(mean);
            squares.add(XminMean.pow(2, context));
        }
        BigDecimal sum = sum(squares);
        return sum.divide(new BigDecimal(biasCorrected ? numbers.size() - 1 : numbers.size()), context);

    }

    /**
     * Calcualtes the square root of the number.
View Full Code Here

            return IntegerValue.makeIntegerValue(hour);
        case Component.MINUTES:
            return IntegerValue.makeIntegerValue(minute);
        case Component.SECONDS:
            BigDecimal d = BigDecimal.valueOf(microsecond);
            d = d.divide(DecimalValue.BIG_DECIMAL_ONE_MILLION, 6, BigDecimal.ROUND_HALF_UP);
            d = d.add(BigDecimal.valueOf(second));
            return new DecimalValue(d);
        case Component.WHOLE_SECONDS: //(internal use only)
            return IntegerValue.makeIntegerValue(second);
        case Component.MICROSECONDS:
View Full Code Here

            return IntegerValue.makeIntegerValue(hour);
        case Component.MINUTES:
            return IntegerValue.makeIntegerValue(minute);
        case Component.SECONDS:
            BigDecimal d = BigDecimal.valueOf(microsecond);
            d = d.divide(DecimalValue.BIG_DECIMAL_ONE_MILLION, 6, BigDecimal.ROUND_HALF_UP);
            d = d.add(BigDecimal.valueOf(second));
            return new DecimalValue(d);
        case Component.WHOLE_SECONDS: //(internal use only)
            return IntegerValue.makeIntegerValue(second);
        case Component.MICROSECONDS:
View Full Code Here

        BigDecimal bd = new BigDecimal(value);
        final String suffix;
        if (bd.compareTo(GB) > 0)
        {
            bd = bd.divide(GB);
            suffix = "GB";
        }
        else if (bd.compareTo(MB) > 0)
        {
            bd = bd.divide(MB);
View Full Code Here

            bd = bd.divide(GB);
            suffix = "GB";
        }
        else if (bd.compareTo(MB) > 0)
        {
            bd = bd.divide(MB);
            suffix = "MB";
        }
        else if (bd.compareTo(KB) > 0)
        {
            bd = bd.divide(KB);
View Full Code Here

            bd = bd.divide(MB);
            suffix = "MB";
        }
        else if (bd.compareTo(KB) > 0)
        {
            bd = bd.divide(KB);
            suffix = "kB";
        }
        else
        {
            suffix = "B";
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.