java.math.BigDecimal.unscaledValue()是java中的一个内置方法,该方法返回BigInteger,其值是BigDecimal值的未缩放值。值进行计算(this * 10this.scale())。
用法:
public BigInteger unscaledValue()
参数:该方法不接受任何参数。
返回值:此方法返回一个BigInteger,其值是此BigDecimal值的未缩放值。
以下示例程序旨在说明BigDecimal.unscaledValue()方法:
示例1:
// Program to illustrate unscaledValue() method of BigDecimal
import java.math.*;
public class Gfg {
public static void main(String[] args)
{
// Creating 2 BigInteger objects
BigInteger i1, i2;
BigDecimal b1 = new BigDecimal("175.856");
BigDecimal b2 = new BigDecimal("-275.73");
// Assigning unscaledValue of BigDecimal objects b1, b2 to i1, i2
i1 = b1.unscaledValue();
i2 = b2.unscaledValue();
// Printing i1, i2 values
System.out.println("The Unscaled Value of " + b1 + " is " + i1);
System.out.println("The Unscaled Value of " + b2 + " is " + i2);
}
}
输出:
The Unscaled Value of 175.856 is 175856 The Unscaled Value of -275.73 is -27573
示例2:
// Program to illustrate unscaledValue() method of BigDecimal
import java.math.*;
public class Gfg {
public static void main(String[] args)
{
// Creating 2 BigInteger objects
BigInteger i1, i2;
BigDecimal b1 = new BigDecimal("5.5");
BigDecimal b2 = new BigDecimal("-2.73");
// Assigning unscaledValue of BigDecimal objects b1, b2 to i1, i2
i1 = b1.unscaledValue();
i2 = b2.unscaledValue();
// Printing i1, i2 values
System.out.println("The Unscaled Value of " + b1 + " is " + i1);
System.out.println("The Unscaled Value of " + b2 + " is " + i2);
}
}
输出:
The Unscaled Value of 5.5 is 55 The Unscaled Value of -2.73 is -273
参考: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#unscaledValue()
相关用法
- Java BigDecimal abs()用法及代码示例
- Java BigDecimal ulp()用法及代码示例
- Java BigDecimal max()用法及代码示例
- Java BigDecimal plus()用法及代码示例
- Java BigDecimal min()用法及代码示例
- Java BigDecimal hashCode()用法及代码示例
- Java BigDecimal add()用法及代码示例
- Java BigDecimal precision()用法及代码示例
- Java BigDecimal intValue()用法及代码示例
- Java BigDecimal longValue()用法及代码示例
- Java BigDecimal round()用法及代码示例
- Java BigDecimal scaleByPowerOfTen()用法及代码示例
- Java BigDecimal intvalueExact()用法及代码示例
- Java BigDecimal scale()用法及代码示例
注:本文由纯净天空筛选整理自Twinkl Bajaj大神的英文原创作品 BigDecimal unscaledValue() in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。