Description Of BigDecimal: divide(BigDecimal divisor, int scale, int roundingMode)
The java.math.BigDecimal.divide(BigDecimal divisor, int scale, int roundingMode) returns a BigDecimal whose value is (this / divisor) , and whose scale is as specified. If rounding must be performed to generate a result with the specified scale, the specified rounding mode is applied.BigDecimal.divide(BigDecimal divisor, int scale, 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, 2, BigDecimal.ROUND_UP)); System.out.println(bg1.divide(bg2, 1, BigDecimal.ROUND_DOWN)); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น