Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/icu/number/FractionPrecision#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/icu/number/FractionPrecision#inhmethods)

# FractionPrecision

*** ** * ** ***


`
public


abstract
class
FractionPrecision
`


`


`

`

extends https://developer.android.com/reference/android/icu/number/Precision


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.icu.number.Precision](https://developer.android.com/reference/android/icu/number/Precision) ||
|   | ↳ | android.icu.number.FractionPrecision |

<br />

*** ** * ** ***

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:**

- `https://developer.android.com/reference/android/icu/number/NumberFormatter`

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/FractionPrecision#withMaxDigits(int)(int maxSignificantDigits) ` Ensure that no more than this number of significant digits are retained when rounding according to fraction rules. |
| ` https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/FractionPrecision#withMinDigits(int)(int minSignificantDigits) ` Ensure that no less than this number of significant digits are retained when rounding according to fraction rules. |
| ` https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/FractionPrecision#withSignificantDigits(int,%20int,%20android.icu.number.NumberFormatter.RoundingPriority)(int minSignificantDigits, int maxSignificantDigits, https://developer.android.com/reference/android/icu/number/NumberFormatter.RoundingPriority priority) ` Override maximum fraction digits with maximum significant digits depending on the magnitude of the number. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/icu/number/Precision ` |---|---| | ` static https://developer.android.com/reference/android/icu/number/CurrencyPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#currency(android.icu.util.Currency.CurrencyUsage)(https://developer.android.com/reference/android/icu/util/Currency.CurrencyUsage currencyUsage) ` Show numbers rounded and padded according to the rules for the currency unit. | | ` static https://developer.android.com/reference/android/icu/number/FractionPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#fixedFraction(int)(int minMaxFractionPlaces) ` Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). | | ` static https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#fixedSignificantDigits(int)(int minMaxSignificantDigits) ` Show numbers rounded if necessary to a certain number of significant digits or significant figures. | | ` static https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#increment(java.math.BigDecimal)(https://developer.android.com/reference/java/math/BigDecimal roundingIncrement) ` Show numbers rounded if necessary to the closest multiple of a certain rounding increment. | | ` static https://developer.android.com/reference/android/icu/number/FractionPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#integer()() ` Show numbers rounded if necessary to the nearest integer. | | ` static https://developer.android.com/reference/android/icu/number/FractionPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#maxFraction(int)(int maxFractionPlaces) ` Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). | | ` static https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#maxSignificantDigits(int)(int maxSignificantDigits) ` Show numbers rounded if necessary to a certain number of significant digits/figures. | | ` static https://developer.android.com/reference/android/icu/number/FractionPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#minFraction(int)(int minFractionPlaces) ` Always show at least a certain number of fraction places after the decimal separator, padding with zeros if necessary. | | ` static https://developer.android.com/reference/android/icu/number/FractionPrecision` | ` https://developer.android.com/reference/android/icu/number/Precision#minMaxFraction(int,%20int)(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 https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#minMaxSignificantDigits(int,%20int)(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 https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#minSignificantDigits(int)(int minSignificantDigits) ` Always show at least a certain number of significant digits/figures, padding with zeros if necessary. | | ` https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#trailingZeroDisplay(android.icu.number.NumberFormatter.TrailingZeroDisplay)(https://developer.android.com/reference/android/icu/number/NumberFormatter.TrailingZeroDisplay trailingZeroDisplay) ` Configure how trailing zeros are displayed on numbers. | | ` static https://developer.android.com/reference/android/icu/number/Precision` | ` https://developer.android.com/reference/android/icu/number/Precision#unlimited()() ` Show all available digits to full precision. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### withMaxDigits

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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".


This is equivalent to `withSignificantDigits(1, maxSignificantDigits, STRICT)`.

<br />

| Parameters ||
|---|---|
| `maxSignificantDigits` | `int`: Round the number to no more than this number of significant figures. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/number/Precision` | A Precision for chaining or passing to the NumberFormatter rounding() setter. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the input number is too big or smaller than 1. |

**See also:**

- `https://developer.android.com/reference/android/icu/number/NumberFormatter`

### withMinDigits

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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".


This is equivalent to `withSignificantDigits(1, minSignificantDigits, RELAXED)`.

<br />

| Parameters ||
|---|---|
| `minSignificantDigits` | `int`: The number of significant figures to guarantee. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/number/Precision` | A Precision for chaining or passing to the NumberFormatter rounding() setter. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the input number is too big or smaller than 1. |

**See also:**

- `https://developer.android.com/reference/android/icu/number/NumberFormatter`

### withSignificantDigits

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Precision withSignificantDigits (int minSignificantDigits, 
                int maxSignificantDigits, 
                NumberFormatter.RoundingPriority priority)
```

Override maximum fraction digits with maximum significant digits depending on the magnitude
of the number. See UNumberRoundingPriority.

<br />

| Parameters ||
|---|---|
| `minSignificantDigits` | `int`: Pad trailing zeros to achieve this minimum number of significant digits. <br /> |
| `maxSignificantDigits` | `int`: Round the number to achieve this maximum number of significant digits. <br /> |
| `priority` | `NumberFormatter.RoundingPriority`: How to disambiguate between fraction digits and significant digits. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/number/Precision` | A precision for chaining or passing to the NumberFormatter precision() setter. <br /> |