NumberFormatter.RoundingPriority


public static final enum NumberFormatter.RoundingPriority
extends Enum<NumberFormatter.RoundingPriority>

java.lang.Object
   ↳ java.lang.Enum<android.icu.number.NumberFormatter.RoundingPriority>
     ↳ android.icu.number.NumberFormatter.RoundingPriority


An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant digits.

There are two modes, RELAXED and STRICT:

  • RELAXED: Relax one of the two constraints (fraction digits or significant digits) in order to round the number to a higher level of precision.
  • STRICT: Enforce both constraints, resulting in the number being rounded to a lower level of precision.

The default settings for compact notation rounding are Max-Fraction = 0 (round to the nearest integer), Max-Significant = 2 (round to 2 significant digits), and priority RELAXED (choose the constraint that results in more digits being displayed).

Conflicting minimum fraction and significant digits are always resolved in the direction that results in more trailing zeros.

Example 1: Consider the number 3.141, with various different settings:

  • Max-Fraction = 1: "3.1"
  • Max-Significant = 3: "3.14"

The rounding priority determines how to resolve the conflict when both Max-Fraction and Max-Significant are set. With RELAXED, the less-strict setting (the one that causes more digits to be displayed) will be used; Max-Significant wins. With STRICT, the more-strict setting (the one that causes fewer digits to be displayed) will be used; Max-Fraction wins.

Example 2: Consider the number 8317, with various different settings:

  • Max-Fraction = 1: "8317"
  • Max-Significant = 3: "8320"

Here, RELAXED favors Max-Fraction and STRICT favors Max-Significant. Note that this larger number caused the two modes to favor the opposite result.

Summary

Enum values

NumberFormatter.RoundingPriority  RELAXED

Favor greater precision by relaxing one of the rounding constraints. 

NumberFormatter.RoundingPriority  STRICT

Favor adherence to all rounding constraints by producing lower precision. 

Public methods

static NumberFormatter.RoundingPriority valueOf(String name)
static final RoundingPriority[] values()

Inherited methods

final Object clone()

Throws CloneNotSupportedException.

final int compareTo(NumberFormatter.RoundingPriority o)

Compares this enum with the specified object for order.

final boolean equals(Object other)

Returns true if the specified object is equal to this enum constant.

final void finalize()

enum classes cannot have finalize methods.

final Class<NumberFormatter.RoundingPriority> getDeclaringClass()

Returns the Class object corresponding to this enum constant's enum type.

final int hashCode()

Returns a hash code for this enum constant.

final String name()

Returns the name of this enum constant, exactly as declared in its enum declaration.

final int ordinal()

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

String toString()

Returns the name of this enum constant, as contained in the declaration.

static <T extends Enum<T>> T valueOf(Class<T> enumClass, String name)

Returns the enum constant of the specified enum class with the specified name.

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 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 wait(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 wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

abstract int compareTo(NumberFormatter.RoundingPriority o)

Compares this object with the specified object for order.

Enum values

RELAXED

Added in API level 34
public static final NumberFormatter.RoundingPriority RELAXED

Favor greater precision by relaxing one of the rounding constraints.

STRICT

Added in API level 34
public static final NumberFormatter.RoundingPriority STRICT

Favor adherence to all rounding constraints by producing lower precision.

Public methods

valueOf

public static NumberFormatter.RoundingPriority valueOf (String name)

Parameters
name String

values

public static final RoundingPriority[] values ()