FractionPrecision
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.
Summary
Public methods |
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.
|
Inherited methods |
From class
android.icu.number.Precision
static
CurrencyPrecision
|
currency(Currency.CurrencyUsage currencyUsage)
Show numbers rounded and padded according to the rules for the currency unit.
|
static
FractionPrecision
|
fixedFraction(int minMaxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the
decimal separator).
|
static
Precision
|
fixedSignificantDigits(int minMaxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits or significant
figures.
|
static
Precision
|
increment(BigDecimal roundingIncrement)
Show numbers rounded if necessary to the closest multiple of a certain rounding increment.
|
static
FractionPrecision
|
integer()
Show numbers rounded if necessary to the nearest integer.
|
static
FractionPrecision
|
maxFraction(int maxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the
decimal separator).
|
static
Precision
|
maxSignificantDigits(int maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures.
|
static
FractionPrecision
|
minFraction(int minFractionPlaces)
Always show at least a certain number of fraction places after the decimal separator, padding with
zeros if necessary.
|
static
FractionPrecision
|
minMaxFraction(int minFractionPlaces, int maxFractionPlaces)
Show numbers rounded if necessary to a certain number of fraction places (numerals after the
decimal separator); in addition, always show at least a certain number of places after the decimal
separator, padding with zeros if necessary.
|
static
Precision
|
minMaxSignificantDigits(int minSignificantDigits, int maxSignificantDigits)
Show numbers rounded if necessary to a certain number of significant digits/figures; in addition,
always show at least a certain number of significant digits, padding with zeros if necessary.
|
static
Precision
|
minSignificantDigits(int minSignificantDigits)
Always show at least a certain number of significant digits/figures, padding with zeros if
necessary.
|
static
Precision
|
unlimited()
Show all available digits to full precision.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
|
Public methods
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 |
int : Round the number to no more than this number of significant figures. |
Returns |
Precision |
A Precision for chaining or passing to the NumberFormatter rounding() setter. |
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 |
int : The number of significant figures to guarantee. |
Returns |
Precision |
A Precision for chaining or passing to the NumberFormatter rounding() setter. |