JavaTM 2 Platform
Standard Ed. 6

类 java.math.RoundingMode
的使用

使用 RoundingMode 的软件包
java.math 提供用于执行任意精度整数算法 (BigInteger) 和任意精度小数算法 (BigDecimal) 的类。 
java.text 提供以与自然语言无关的方式来处理文本、日期、数字和消息的类和接口。 
 

java.mathRoundingMode 的使用
 

返回 RoundingModejava.math 中的方法
 RoundingMode MathContext.getRoundingMode()
          返回 roundingMode 设置。
static RoundingMode RoundingMode.valueOf(int rm)
          返回与 BigDecimal 中遗留整数舍入模式常量对应的 RoundingMode 对象。
static RoundingMode RoundingMode.valueOf(String name)
          返回带有指定名称的该类型的枚举常量。
static RoundingMode[] RoundingMode.values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 

参数类型为 RoundingModejava.math 中的方法
 BigDecimal BigDecimal.divide(BigDecimal divisor, int scale, RoundingMode roundingMode)
          返回一个 BigDecimal,其值为 (this / divisor),其标度为指定标度。
 BigDecimal BigDecimal.divide(BigDecimal divisor, RoundingMode roundingMode)
          返回一个 BigDecimal,其值为 (this / divisor),其标度为 this.scale()
 BigDecimal BigDecimal.setScale(int newScale, RoundingMode roundingMode)
          返回 BigDecimal,其标度为指定值,其非标度值通过此 BigDecimal 的非标度值乘以或除以十的适当次幂来确定,以维护其总值。
 

参数类型为 RoundingModejava.math 中的构造方法
MathContext(int setPrecision, RoundingMode setRoundingMode)
          构造一个新的 MathContext,它具有指定的精度和舍入模式。
 

java.textRoundingMode 的使用
 

返回 RoundingModejava.text 中的方法
 RoundingMode DecimalFormat.getRoundingMode()
          获取在此 DecimalFormat 中使用的 RoundingMode
 RoundingMode NumberFormat.getRoundingMode()
          获取在此 NumberFormat 中使用的 RoundingMode
 

参数类型为 RoundingModejava.text 中的方法
 void DecimalFormat.setRoundingMode(RoundingMode roundingMode)
          设置在此 DecimalFormat 中使用的 RoundingMode
 void NumberFormat.setRoundingMode(RoundingMode roundingMode)
          设置在此 NumberFormat 中使用的 RoundingMode
 


JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only