from

fun from(s: String?, suppressedExponent: Int = 0): PluralOperand?

Create a PluralOperand from a String.

Using a String or BigDecimal instead of a float or double allows for the determination of trailing zeros and visible fraction digits, which can have an impact on number format selection depending upon the locale.

Return

PluralOperand, or empty Optional if the String cannot be parsed into a BigDecimal

Parameters

s

a Number, as a String. Null-safe.


fun from(input: Number, suppressedExponent: Int = 0): PluralOperand

Create a PluralOperand from a given Number type.

This selects the most specific type:

  • BigInteger, BigDecimal: handled using BigDecimal type

  • Double, Float: handled using double type

  • all others (long, int, short, byte): handled using long type

Null values will result in a NullPointerException

Return

PluralOperand

Parameters

input

Number


fun from(input: Int, suppressedExponent: Int = 0): PluralOperand
fun from(input: Long, suppressedExponent: Int = 0): PluralOperand

Explicitly set suppressedExponent for Compact format numbers. The exponent is explicitly denoted; e.g., fromCompact(1L, 6) is equivalent to "1 Million" However, fromCompact(1000000L, 6) will result in "1000000 million"

Return

PluralOperand

Parameters

input

input as a long

suppressedExponent

(must be between 0 and 21)


fun from(input: Double, suppressedExponent: Int = 0): PluralOperand

Explicitly set suppressedExponent for Compact format numbers.

The exponent must be explicitly denoted; e.g., fromCompact(1L, 6) is equivalent to "1 Million" However, fromCompact(1000000L, 6) will result in "1000000 million"

Note that for fromCompact(1.2, 6) the operands are (n = 1.2, i = 1200000, c = 6)

It is not possible to determine precision (trailing zeros) from double input.

Return

PluralOperand

Parameters

input

input as a double

suppressedExponent

(must be between 0 and 21)