Package com.ibm.icu.number
Class FractionPrecision
- java.lang.Object
-
- com.ibm.icu.number.Precision
-
- com.ibm.icu.number.FractionPrecision
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
FractionRounder
public abstract class FractionPrecision extends Precision
A class that defines a rounding strategy based on a number of fraction places and optionally significant digits to be used when formatting numbers in NumberFormatter.To create a FractionPrecision, use one of the factory methods on Precision.
- See Also:
NumberFormatter
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Precision
withMaxDigits(int maxSignificantDigits)
Ensure that no more than this number of significant digits are retained when rounding according to fraction rules.Precision
withMinDigits(int minSignificantDigits)
Ensure that no less than this number of significant digits are retained when rounding according to fraction rules.-
Methods inherited from class com.ibm.icu.number.Precision
apply, clone, currency, fixedDigits, fixedFraction, fixedSignificantDigits, increment, integer, maxDigits, maxFraction, maxSignificantDigits, minDigits, minFraction, minMaxDigits, minMaxFraction, minMaxSignificantDigits, minSignificantDigits, unlimited, withMode, withMode
-
-
-
-
Method Detail
-
withMinDigits
public Precision withMinDigits(int minSignificantDigits)
Ensure that no less than this number of significant digits are retained when rounding according to fraction rules.For example, with integer rounding, the number 3.141 becomes "3". However, with minimum figures set to 2, 3.141 becomes "3.1" instead.
This setting does not affect the number of trailing zeros. For example, 3.01 would print as "3", not "3.0".
- Parameters:
minSignificantDigits
- The number of significant figures to guarantee.- Returns:
- A Precision for chaining or passing to the NumberFormatter rounding() setter.
- See Also:
NumberFormatter
-
withMaxDigits
public Precision withMaxDigits(int maxSignificantDigits)
Ensure that no more than this number of significant digits are retained when rounding according to fraction rules.For example, with integer rounding, the number 123.4 becomes "123". However, with maximum figures set to 2, 123.4 becomes "120" instead.
This setting does not affect the number of trailing zeros. For example, with fixed fraction of 2, 123.4 would become "120.00".
- Parameters:
maxSignificantDigits
- Round the number to no more than this number of significant figures.- Returns:
- A Precision for chaining or passing to the NumberFormatter rounding() setter.
- See Also:
NumberFormatter
-
-