BigNum

class BigNum(val int: BigInt, val scale: Int) : Comparable<BigNum>

Represents a BigNum, a numeric value with decimal places that is exact.

There are no precision issues like happens with Float or Double floating point types.

Constructors

Link copied to clipboard
constructor(int: BigInt, scale: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns the decimal part as a BigInt of this BigNum so for 1.9123.bn it will return 9123.bi

Link copied to clipboard
val int: BigInt
Link copied to clipboard
val scale: Int

Functions

Link copied to clipboard
open operator override fun compareTo(other: BigNum): Int
Link copied to clipboard
fun convertToScale(otherScale: Int): BigNum

Converts the internal scale of this BigNum to otherScale while keeping the same value.

Link copied to clipboard
operator fun div(other: BigNum): BigNum

Performs this / other returning a BigNum

fun div(other: BigNum, precision: Int): BigNum

Performs this / other returning a BigNum using a specific precision

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
operator fun minus(other: BigNum): BigNum

Performs this - other returning a BigNum, if the scale is different for both numbers, it finds a common one

Link copied to clipboard
operator fun plus(other: BigNum): BigNum

Performs this + other returning a BigNum, if the scale is different for both numbers, it finds a common one

Link copied to clipboard
infix fun pow(exponent: Int): BigNum

Performs this ** exponent

fun pow(exponent: Int, precision: Int): BigNum

Performs this ** exponent with a specific precision

Link copied to clipboard
operator fun rangeTo(that: BigNum): ClosedBigNumRange

Creates a ClosedBigNumRange between this and that

Link copied to clipboard
operator fun times(other: BigNum): BigNum

Performs this * other returning a BigNum, the scale ends being the sum of both scales

Link copied to clipboard

Converts this BigInt effectively losing the decimal places

Link copied to clipboard

Converts this BigInt doing ceiling when there are decimals

Link copied to clipboard

Converts this BigInt doing flooring when there are decimals

Link copied to clipboard

Converts this BigInt doing rounding when there are decimals

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