Description Of BigDecimal: divide(BigDecimal divisor, RoundingMode roundingMode)
The java.math.BigDecimal.divide(BigDecimal divisor, RoundingMode 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, RoundingMode roundingMode) method returns this / divisor
Code Example Java BigDecimal
import java.math.BigDecimal; import java.math.RoundingMode; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("10"); BigDecimal bg2 = new BigDecimal("3"); BigDecimal bg3 = bg1.divide(bg2, RoundingMode.UP); System.out.println(bg3); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น