Java Math BigDecimal.scaleByPowerOfTen() 方法 Java Math BigDecimal.scale() 方法 Java Math BigDecimal.setScale() 方法 Java Math BigDecimal.scaleByPowerOfTen() 方法 package com.codingdict; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 4 BigDecimal objects BigDecimal bg1, bg2, bg3, bg4; bg1 = new BigDecimal("235.000"); bg2 = new BigDecimal("23500"); // assign the result of method on bg1, bg2 to bg3, bg4 bg3 = bg1.scaleByPowerOfTen(3); bg4 = bg2.scaleByPowerOfTen(-3); String str1 = bg1 + " raised to 10 power 3 is " +bg3; String str2 = bg2 + " raised to 10 power -3 is " +bg4; // print bg3, bg4 values System.out.println( str1 ); System.out.println( str2 ); } } Java Math BigDecimal.scale() 方法 Java Math BigDecimal.setScale() 方法