Description Of BigDecimal: divide(BigDecimal divisor, int roundingMode)
The java.math.BigDecimal.divide(BigDecimal divisor, int roundingMode) returns a BigDecimal whose value is (this / divisor) , and whose scale is this.scale() . If rounding must be performed to generate a result with the given scale, the specified rounding mode is applied.BigDecimal.divide(BigDecimal divisor, int roundingMode) method returns this / divisor
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("10"); BigDecimal bg2 = new BigDecimal("3"); System.out.println(bg1.divide(bg2, BigDecimal.ROUND_UP)); System.out.println(bg1.divide(bg2, BigDecimal.ROUND_DOWN)); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น