Ratio

@Serializable(with = RatioSerializer::class)
data class Ratio(val top: Int, val bottom: Int)

Represents a ratio of top out of bottom, serialized as a human-readable string like "3 / 10 (30.00%)".

Constructors

Link copied to clipboard
constructor(top: Int, bottom: Int)

Types

Link copied to clipboard
object Companion

Predefined Ratio constants.

Properties

Link copied to clipboard
val bottom: Int

Denominator of the ratio; a value of 0 yields a 0% ratio rather than a division error.

Link copied to clipboard

The ratio as a fraction in [0, 1], or 0.0 when bottom is 0.

Link copied to clipboard
val top: Int

Numerator of the ratio.

Functions

Link copied to clipboard
open override fun toString(): String

Renders the ratio as "top / bottom (percent%)", e.g. "3 / 10 (30.00%)".