Package java.math

Examples of java.math.RoundingMode


        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.HALF_DOWN;
        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


        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 21;
        RoundingMode rm = RoundingMode.HALF_EVEN;
        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

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 32;
        RoundingMode rm = RoundingMode.UP;
        MathContext mc = new MathContext(precision, rm);
        String c = "277923185514690367474770683";
        int resScale = 0;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

        String a = "3736186567876876578956958769675785435673453453653543654354365435675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 70;
        int precision = 75;
        RoundingMode rm = RoundingMode.DOWN;
        MathContext mc = new MathContext(precision, rm);
        String c = "2.7792318551469036747477068339450205874992634417590178670822889E+62";
        int resScale = -1;
        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 = 75;
        RoundingMode rm = RoundingMode.UP;
        MathContext mc = new MathContext(precision, rm);
        String res = "277923185514690367474770683";
        int resScale = 0;
        String rem = "1.3032693871288309587558885943391070087960319452465789990E-15";
        int remScale = 70;
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 20;
        int precision = 15;
        RoundingMode rm = RoundingMode.DOWN;
        MathContext mc = new MathContext(precision, rm);
        String res = "0E-25";
        int resScale = 25;
        String rem = "3736186567876.876578956958765675671119238118911893939591735";
        int remScale = 45;
View Full Code Here

        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        String b = "134432345432345748766876876723342238476237823787879183470";
        int bScale = 10;
        int precision = 15;
        RoundingMode rm = RoundingMode.HALF_UP;
        MathContext mc = new MathContext(precision, rm);
        String res = "3736186567876.876578956958765675671119238118911893939591735";
        int resScale = 45;
        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 = 10;
        int precision = 75;
        RoundingMode rm = RoundingMode.HALF_DOWN;
        MathContext mc = new MathContext(precision, rm);
        String res = "1149310942946292909508821656680979993738625937.2065885780";
        int resScale = 10;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
View Full Code Here

     */
    public void testRoundMathContextHALF_DOWN() {
        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = -45;
        int precision = 75;
        RoundingMode rm = RoundingMode.HALF_DOWN;
        MathContext mc = new MathContext(precision, rm);
        String res = "3.736186567876876578956958765675671119238118911893939591735E+102";
        int resScale = -45;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal result = aNumber.round(mc);
View Full Code Here

     */
    public void testRoundMathContextHALF_UP() {
        String a = "3736186567876876578956958765675671119238118911893939591735";
        int aScale = 45;
        int precision = 15;
        RoundingMode rm = RoundingMode.HALF_UP;
        MathContext mc = new MathContext(precision, rm);
        String res = "3736186567876.88";
        int resScale = 2;
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        BigDecimal result = aNumber.round(mc);
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.