# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Methods | Inherited Methods

# Precision

`public abstract class Precision`
`extends Object` ``

java.lang.Object
↳ | android.icu.number.Precision

Known direct subclasses CurrencyPrecision, FractionPrecision
CurrencyPrecision | A class that defines a rounding strategy parameterized by a currency to be used when formatting numbers in NumberFormatter.
FractionPrecision | 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.

A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.

To create a Precision, use one of the factory methods.

See also:

- `NumberFormatter`

## Summary

### Public methods
`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.

### Inherited methods
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

### currency

    public static CurrencyPrecision currency (Currency.CurrencyUsage currencyUsage)

Show numbers rounded and padded according to the rules for the currency unit. The most common rounding precision settings for currencies include `Precision.fixedFraction(2)`, `Precision.integer()`, and `Precision.increment(0.05)` for cash transactions ("nickel rounding").

The exact rounding details will be resolved at runtime based on the currency unit specified in the NumberFormatter chain. To round according to the rules for one currency while displaying the symbol for another currency, the withCurrency() method can be called on the return value of this method.

Parameters
`currencyUsage` | `Currency.CurrencyUsage`: Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may be limited by the available denominations of cash or coins).

Returns
`CurrencyPrecision` | A CurrencyPrecision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if currencyUsage is null.

See also:

- `NumberFormatter`

### fixedFraction

    public static FractionPrecision fixedFraction (int minMaxFractionPlaces)

Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). Additionally, pad with zeros to ensure that this number of places are always shown.

Example output with minMaxFractionPlaces = 3:

87,650.000
8,765.000
876.500
87.650
8.765
0.876
0.088
0.009
0.000 (zero)

This method is equivalent to `minMaxFraction(int, int)` with both arguments equal.

Parameters
`minMaxFractionPlaces` | `int`: The minimum and maximum number of numerals to display after the decimal separator (rounding if too long or padding with zeros if too short).

Returns
`FractionPrecision` | A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 0.

See also:

- `NumberFormatter`

### fixedSignificantDigits

    public static Precision fixedSignificantDigits (int minMaxSignificantDigits)

Show numbers rounded if necessary to a certain number of significant digits or significant figures. Additionally, pad with zeros to ensure that this number of significant digits/figures are always shown.

This method is equivalent to `minMaxSignificantDigits(int, int)` with both arguments equal.

Parameters
`minMaxSignificantDigits` | `int`: The minimum and maximum number of significant digits to display (rounding if too long or padding with zeros if too short).

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 1.

See also:

- `NumberFormatter`

### increment

    public static Precision increment (BigDecimal roundingIncrement)

Show numbers rounded if necessary to the closest multiple of a certain rounding increment. For example, if the rounding increment is 0.5, then round 1.2 to 1 and round 1.3 to 1.5.

In order to ensure that numbers are padded to the appropriate number of fraction places, set the scale on the rounding increment BigDecimal. For example, to round to the nearest 0.5 and always display 2 numerals after the decimal separator (to display 1.2 as "1.00" and 1.3 as "1.50"), you can run:

     Precision.increment(new BigDecimal("0.50"))

For more information on the scale of Java BigDecimal, see `BigDecimal.scale()`.

Parameters
`roundingIncrement` | `BigDecimal`: The increment to which to round numbers.

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the rounding increment is null or non-positive.

See also:

- `NumberFormatter`

### integer

    public static FractionPrecision integer ()

Show numbers rounded if necessary to the nearest integer.

Returns
`FractionPrecision` | A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.

See also:

- `NumberFormatter`

### maxFraction

    public static FractionPrecision maxFraction (int maxFractionPlaces)

Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). Unlike the other fraction rounding strategies, this strategy does not pad zeros to the end of the number.

Parameters
`maxFractionPlaces` | `int`: The maximum number of numerals to display after the decimal mark (rounding if necessary).

Returns
`FractionPrecision` | A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 0.

See also:

- `NumberFormatter`

### maxSignificantDigits

    public static Precision maxSignificantDigits (int maxSignificantDigits)

Show numbers rounded if necessary to a certain number of significant digits/figures.

Parameters
`maxSignificantDigits` | `int`: The maximum number of significant digits to display (rounding if too long).

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 1.

See also:

- `NumberFormatter`

### minFraction

    public static FractionPrecision minFraction (int minFractionPlaces)

Always show at least a certain number of fraction places after the decimal separator, padding with zeros if necessary. Do not perform rounding (display numbers to their full precision).

NOTE: If you are formatting doubles, see the performance note in `unlimited()`.

Parameters
`minFractionPlaces` | `int`: The minimum number of numerals to display after the decimal separator (padding with zeros if necessary).

Returns
`FractionPrecision` | A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 0.

See also:

- `NumberFormatter`

### minMaxFraction

    public 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.

Parameters
`minFractionPlaces` | `int`: The minimum number of numerals to display after the decimal separator (padding with zeros if necessary).
`maxFractionPlaces` | `int`: The maximum number of numerals to display after the decimal separator (rounding if necessary).

Returns
`FractionPrecision` | A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 0.

See also:

- `NumberFormatter`

### minMaxSignificantDigits

    public 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.

Parameters
`minSignificantDigits` | `int`: The minimum number of significant digits to display (padding with zeros if necessary).
`maxSignificantDigits` | `int`: The maximum number of significant digits to display (rounding if necessary).

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 1.

See also:

- `NumberFormatter`

### minSignificantDigits

    public static Precision minSignificantDigits (int minSignificantDigits)

Always show at least a certain number of significant digits/figures, padding with zeros if necessary. Do not perform rounding (display numbers to their full precision).

NOTE: If you are formatting doubles, see the performance note in `unlimited()`.

Parameters
`minSignificantDigits` | `int`: The minimum number of significant digits to display (padding with zeros if too short).

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

Throws
`IllegalArgumentException` | if the input number is too big or smaller than 1.

See also:

- `NumberFormatter`

### unlimited

    public static Precision unlimited ()

Show all available digits to full precision.

NOTE: When formatting a double, this method, along with `minFraction(int)` and `minSignificantDigits(int)`, will trigger complex algorithm similar to Dragon4 to determine the low-order digits and the number of digits to display based on the value of the double. If the number of fraction places or significant digits can be bounded, consider using `maxFraction(int)` or `maxSignificantDigits(int)` instead to maximize performance. For more information, read the following blog post.

http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/

Returns
`Precision` | A Precision for chaining or passing to the NumberFormatter precision() setter.

See also:

- `NumberFormatter`

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*