Package java.math

Examples of java.math.RoundingMode


        String a = "-37361671119238118911893939591735";
        int aScale = 10;
        String b = "74723342238476237823787879183470";
        int bScale = 15;
        int newScale = 31;
        RoundingMode rm = RoundingMode.DOWN;
        String c = "-50000.0000000000000000000000000000000";
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
        BigDecimal result = aNumber.divide(bNumber, newScale, rm);
        assertEquals("incorrect value", c, result.toString());
View Full Code Here


        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 100;
        String b = "74723342238476237823787879183470";
        int bScale = 15;
        int newScale = 45;
        RoundingMode rm = RoundingMode.FLOOR;
        String c = "0E-45";
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
        BigDecimal result = aNumber.divide(bNumber, newScale, rm);
        assertEquals("incorrect value", c, result.toString());
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = -51;
        String b = "74723342238476237823787879183470";
        int bScale = 45;
        int newScale = 3;
        RoundingMode rm = RoundingMode.HALF_UP;
        String c = "50000260373164286401361913262100972218038099522752460421" +
                   "05959924024355721031761947728703598332749334086415670525" +
                   "3761096961.670";
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 5;
        String b = "74723342238476237823787879183470";
        int bScale = 15;
        int newScale = 7;
        RoundingMode rm = RoundingMode.HALF_DOWN;
        String c = "500002603731642864013619132621009722.1803810";
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
        BigDecimal result = aNumber.divide(bNumber, newScale, rm);
        assertEquals("incorrect value", c, result.toString());
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 5;
        String b = "74723342238476237823787879183470";
        int bScale = 15;
        int newScale = 7;
        RoundingMode rm = RoundingMode.HALF_EVEN;
        String c = "500002603731642864013619132621009722.1803810";
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
        BigDecimal result = aNumber.divide(bNumber, newScale, rm);
        assertEquals("incorrect value", c, result.toString());
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 15;
        String b = "748766876876723342238476237823787879183470";
        int bScale = 10;
        int precision = 21;
        RoundingMode rm = RoundingMode.UP;
        MathContext mc = new MathContext(precision, rm);
        String c = "49897861180.2562512996";
        int resScale = 10;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 15;
        String b = "748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.DOWN;
        MathContext mc = new MathContext(precision, rm);
        String c = "4.98978611802562512995E+70";
        int resScale = -50;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 15;
        String b = "748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.CEILING;
        MathContext mc = new MathContext(precision, rm);
        String c = "4.98978611802562512996E+70";
        int resScale = -50;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 15;
        String b = "748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.FLOOR;
        MathContext mc = new MathContext(precision, rm);
        String c = "4.98978611802562512995E+70";
        int resScale = -50;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.HALF_UP;
        MathContext mc = new MathContext(precision, rm);
        String c = "2.77923185514690367475E+26";
        int resScale = -6;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

TOP

Related Classes of java.math.RoundingMode

Copyright © 2018 www.massapicom. 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.