Package-level declarations

Core functions and types.

Types

Link copied to clipboard

Represents a percentage number, a numerical value divided by 100.

Functions

Link copied to clipboard
infix fun Number.decreaseBy(percentage: Percentage): Number

Decreases this number by the given Percentage.

Link copied to clipboard
infix fun Number.increaseBy(percentage: Percentage): Number

Increases this number by the given Percentage.

Link copied to clipboard

Creates a Percentage based on a number returned by the lambda function. Calculations using it won't be rounded.

Creates a Percentage based on this number. Calculations using it won't be rounded.

fun () -> Number.percent(rounding: Rounding): Percentage
fun () -> Number.percent(precision: Int): Percentage

Creates a Percentage based on a number returned by the lambda function. Calculations using it will be rounded.

infix fun Number.percent(rounding: Rounding): Percentage
infix fun Number.percent(precision: Int): Percentage

Creates a Percentage based on this number. Calculations using it will be rounded.

Link copied to clipboard
infix fun Number.ratioOf(other: Number): Percentage

Creates a Percentage based on the ratio of this number and other number. Calculations using it won't be rounded. Example:

fun Number.ratioOf(other: Number, rounding: Rounding): Percentage
fun Number.ratioOf(other: Number, precision: Int): Percentage

Creates a Percentage based on the ratio of this number and other number. Calculations using it will be rounded. Example:

Link copied to clipboard

Creates a Percentage which represents the relative change of this number to another number. Calculations using it won't be rounded. Example:

fun Number.relativeChange(other: Number, precision: Int): Percentage

Creates a Percentage which represents the relative change of this number to another number. Calculations using it will be rounded. Example:

Link copied to clipboard

Sums all Percentage elements in the collection. The rounding strategy of the first element is preserved in the resulting Percentage.

Link copied to clipboard
operator fun Number.times(percentage: Percentage): Double

Multiplies this number by the given Percentage.

Link copied to clipboard

Returns a detailed string representation of the object.

Link copied to clipboard
infix fun Number.valueWhen(percentage: Percentage): Double

Calculates the base value of this number for the given Percentage. This method helps to answer the question: "5 is 20% of what number?" Example: