JavaTM Platform
Standard Ed. 6

类 java.math.RoundingMode
的使用

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

java.math 中 RoundingMode 的使用
 

返回 RoundingMode 的 java.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.
 

参数类型为 RoundingMode 的 java.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 的非标度值乘以或除以十的适当次幂来确定,以维护其总值。
 

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

java.text 中 RoundingMode 的使用
 

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

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


JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。