Java数学除法(RoundingMode) Java Math divide(MathContext mc) Java Math divideAndRemainder() 方法 Java数学除法(RoundingMode) package com.codingdict; import java.math.*; import java.lang.*; public class BigDecimalDemo { public static void main(String[] args) { // create 3 BigDecimal objects BigDecimal bg1, bg2, bg3; bg1 = new BigDecimal("16"); bg2 = new BigDecimal("3"); // divide bg1 with bg2 rounding up bg3 = bg1.divide(bg2, RoundingMode.UP); String str = "Division result is " +bg3; // print bg3 value System.out.println( str ); } } Java Math divide(MathContext mc) Java Math divideAndRemainder() 方法