Java Math Bigdecimal_subtract_mc Java Math BigDecimal.subtract() 方法 Java Math BigDecimal.toBigInteger() 方法 Java Math Bigdecimal_subtract_mc package com.codingdict; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 3 BigDecimal objects BigDecimal bg1, bg2, bg3; MathContext mc = new MathContext(2); // 2 precision bg1 = new BigDecimal("100.123"); bg2 = new BigDecimal("50.56"); // subtract bg1 with bg2 using mc and assign result to bg3 bg3 = bg1.subtract(bg2, mc); String str = "The Result of Subtraction is " + bg3; // print bg3 value System.out.println( str ); } } Java Math BigDecimal.subtract() 方法 Java Math BigDecimal.toBigInteger() 方法