Package-level declarations

Properties

Link copied to clipboard
val Int.GB: Long

This value in gigabytes (multiples of 1000^3) expressed as bytes.

Link copied to clipboard
val Int.GiB: Long

This value in gibibytes (multiples of 1024^3) expressed as bytes.

Link copied to clipboard
val Int.KB: Long

This value in kilobytes (multiples of 1000) expressed as bytes.

Link copied to clipboard
val Int.KiB: Long

This value in kibibytes (multiples of 1024) expressed as bytes.

Link copied to clipboard
val Int.MB: Long

This value in megabytes (multiples of 1000^2) expressed as bytes.

Link copied to clipboard
val Int.MiB: Long

This value in mebibytes (multiples of 1024^2) expressed as bytes.

Functions

Link copied to clipboard
fun Double.ceilTo(decimals: Int): Double

Returns this value rounded up (toward positive infinity) at decimals fractional digits.

Link copied to clipboard

Clamps this value into 0.0..1.0. NaN stays NaN.

Clamps this value into 0f..1f. NaN stays NaN.

Link copied to clipboard

Returns the number of decimal digits in the absolute value of this number.

Link copied to clipboard
fun Int.digits(): List<Int>

Returns the decimal digits of the absolute value of this number, most significant first.

Link copied to clipboard
fun factorial(n: Int): Long

Returns the factorial of n.

Link copied to clipboard
fun Double.floorTo(decimals: Int): Double

Returns this value rounded down (toward negative infinity) at decimals fractional digits.

Link copied to clipboard
fun Long.formatBytes(decimals: Int = 1, si: Boolean = false): String

Formats this byte count as a human-readable size string such as "1.5 KiB".

Link copied to clipboard
fun Float.formatDecimals(decimals: Int): String

Formats this value with exactly decimals fractional digits, locale-independent.

Link copied to clipboard
fun Int.formatGrouped(separator: Char = ','): String
fun Long.formatGrouped(separator: Char = ','): String

Formats this value in decimal with separator between each group of three digits.

Link copied to clipboard
fun Double.formatPercent(decimals: Int = 0): String

Formats this fraction as a percentage string, so 0.42.formatPercent() is "42%".

Link copied to clipboard
fun gcd(a: Int, b: Int): Int
fun gcd(a: Long, b: Long): Long

Returns the greatest common divisor of a and b.

Link copied to clipboard
fun Int.hasFlag(flag: Int): Boolean

Returns true when every bit of flag is set in this mask.

Link copied to clipboard
fun inverseLerp(start: Double, stop: Double, value: Double): Double

Returns the fraction at which value lies between start and stop.

Link copied to clipboard
fun Double.isApproximately(other: Double, epsilon: Double = 1.0E-9): Boolean
fun Float.isApproximately(other: Float, epsilon: Float = 1.0E-6f): Boolean

Returns true when this value is within epsilon of other.

Link copied to clipboard

Returns true when this value is evenly divisible by two.

Link copied to clipboard

Returns true when this value is not evenly divisible by two.

Link copied to clipboard

Returns true when this value is a positive power of two.

Link copied to clipboard

Returns true when n is a prime number.

Link copied to clipboard
fun lcm(a: Int, b: Int): Long

Returns the least common multiple of a and b as a Long.

fun lcm(a: Long, b: Long): Long

Returns the least common multiple of a and b.

Link copied to clipboard
fun lerp(start: Double, stop: Double, fraction: Double): Double
fun lerp(start: Float, stop: Float, fraction: Float): Float

Linearly interpolates between start and stop by fraction.

Link copied to clipboard
fun Int.midpoint(other: Int): Int
fun Long.midpoint(other: Long): Long

Returns the midpoint of this value and other without intermediate overflow.

Link copied to clipboard

Returns the smallest power of two that is greater than or equal to this value.

Link copied to clipboard

Returns the English ordinal suffix for this number: "st", "nd", "rd", or "th".

Link copied to clipboard
fun Int.percentOf(total: Int): Double

Returns the percentage that this value represents of total.

Link copied to clipboard
fun Int.pow(exponent: Int): Long

Raises this value to the given non-negative exponent and returns the result as a Long.

Link copied to clipboard
fun Double.remap(fromStart: Double, fromEnd: Double, toStart: Double, toEnd: Double): Double

Remaps this value from the range fromStart..fromEnd to the range toStart..toEnd.

Link copied to clipboard
fun Double.roundTo(decimals: Int): Double
fun Float.roundTo(decimals: Int): Float

Returns this value rounded to decimals fractional digits.

Link copied to clipboard

Returns the multiple of step closest to this value.

Link copied to clipboard

Converts this angle in radians to degrees.

Link copied to clipboard
fun Int.toggleFlag(flag: Int): Int

Returns this mask with every bit of flag inverted.

Link copied to clipboard

Converts this angle in degrees to radians.

Link copied to clipboard
fun Int.withFlag(flag: Int): Int

Returns this mask with every bit of flag set.

Link copied to clipboard

Returns this number followed by its English ordinal suffix, such as "21st".

Link copied to clipboard
fun Int.withoutFlag(flag: Int): Int

Returns this mask with every bit of flag cleared.