public abstract class FractionPrecision extends Precision
To create a FractionPrecision, use one of the factory methods on Precision.
NumberFormatter
Precision.BogusRounder
BOGUS_PRECISION
Modifier and Type | Method and 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.
|
Precision |
withSignificantDigits(int minSignificantDigits,
int maxSignificantDigits,
NumberFormatter.RoundingPriority priority)
Override maximum fraction digits with maximum significant digits depending on the magnitude
of the number.
|
apply, currency, fixedFraction, fixedSignificantDigits, increment, integer, maxFraction, maxSignificantDigits, minFraction, minMaxFraction, minMaxSignificantDigits, minSignificantDigits, trailingZeroDisplay, unlimited, withMode
public Precision withSignificantDigits(int minSignificantDigits, int maxSignificantDigits, NumberFormatter.RoundingPriority priority)
minSignificantDigits
- Pad trailing zeros to achieve this minimum number of significant digits.maxSignificantDigits
- Round the number to achieve this maximum number of significant digits.priority
- How to disambiguate between fraction digits and significant digits.public Precision withMinDigits(int minSignificantDigits)
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".
This is equivalent to withSignificantDigits(1, minSignificantDigits, RELAXED)
.
minSignificantDigits
- The number of significant figures to guarantee.IllegalArgumentException
- if the input number is too big or smaller than 1.NumberFormatter
public Precision withMaxDigits(int maxSignificantDigits)
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".
This is equivalent to withSignificantDigits(1, maxSignificantDigits, STRICT)
.
maxSignificantDigits
- Round the number to no more than this number of significant figures.IllegalArgumentException
- if the input number is too big or smaller than 1.NumberFormatter
Copyright © 2016 Unicode, Inc. and others.