- Java.math 包额外内容
- Java.math - 枚举
- Java.math - 讨论
Java.math.BigDecimal.unscaledValue() 方法
说明
java.math.BigDecimal.unscaledValue() 返回一个 BigInteger,其值为该 BigDecimal 的未缩放值。(计算 (this * 10this.scale()))。
声明
以下是 java.math.BigDecimal.unscaledValue() 方法的声明。
public BigInteger unscaledValue()
参数
无效
返回值
此方法返回该 BigDecimal 的未缩放值。
异常
无效
示例
以下示例演示了如何使用 math.BigDecimal.unscaledValue() 方法。
package com.tutorialspoint;
import java.math.*;
public class BigDecimalDemo {
public static void main(String[] args) {
// create 2 BigDecimal objects
BigDecimal bg1, bg2;
// create 2 BigInteger objects
BigInteger bi1, bi2;
bg1 = new BigDecimal("123.12");
bg2 = new BigDecimal("-245.03");
// assign unscaledValue of bg1,bg2 to bi1,bi2
bi1 = bg1.unscaledValue();
bi2 = bg2.unscaledValue();
String str1 = "The Unscaled Value of " + bg1 + " is " + bi1;
String str2 = "The Unscaled Value of " + bg2 + " is " + bi2;
// print bi1, bi2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
让我们编译并运行上述程序,这会产生以下结果 −
The Unscaled Value of 123.12 is 12312 The Unscaled Value of -245.03 is -24503
java_math_bigdecimal.htm
广告