Scoop API

scoop:scoop.math:0.1.0

BigDecimal

class BigDecimal

source · line 7
public
public class BigDecimal internal constructor(
    private val coefficient: IntegerStorage,
    /** The decimal scale; negative scales represent integer powers of ten. */
    public val scale: Long
) : Equals<BigDecimal>, Compare<BigDecimal>, Hash, ToString, Add<BigDecimal, BigDecimal>, Sub<BigDecimal, BigDecimal>, Mul<BigDecimal, BigDecimal>, Div<BigDecimal, BigDecimal>, Rem<BigDecimal, BigDecimal>, UnaryPlus<BigDecimal>, UnaryMinus<BigDecimal>, Increment<BigDecimal>, Decrement<BigDecimal>

An immutable arbitrary-precision decimal, coefficient * 10^(-scale). Equality and hashing compare numerical values, ignoring scale; sameRepresentation compares stored representations.

function toFloat

source · line 153
public
public fun toFloat(): Float

Rounds directly to binary32, allowing infinity and signed underflow zero.

function unscaledValue

source · line 28
public
public fun unscaledValue(): BigInteger

Returns the immutable signed coefficient, without applying the scale.

function toShortExact

source · line 163
public
public fun toShortExact(): Short

Requires both an integral value and a representable Short; otherwise throws ArithmeticException.

function toEngineeringString

source · line 46
public
public fun toEngineeringString(): String

Uses an exponent divisible by three when scientific notation is needed.

function toByteExact

source · line 159
public
public fun toByteExact(): Byte

Requires both an integral value and a representable Byte; otherwise throws ArithmeticException.

function toBigInteger

source · line 149
public
public fun toBigInteger(): BigInteger

Truncates toward zero and returns an immutable integer.

function toULongExact

source · line 187
public
public fun toULongExact(): ULong

Requires both an integral value and a representable ULong; otherwise throws ArithmeticException.

function inc

source · line 63
public
public override operator fun inc(): BigDecimal

Returns this value plus the scale-zero constant one.

function toIntExact

source · line 167
public
public fun toIntExact(): Int

Requires both an integral value and a representable Int; otherwise throws ArithmeticException.

function toUByteExact

source · line 175
public
public fun toUByteExact(): UByte

Requires both an integral value and a representable UByte; otherwise throws ArithmeticException.

function toUShortExact

source · line 179
public
public fun toUShortExact(): UShort

Requires both an integral value and a representable UShort; otherwise throws ArithmeticException.

function stripTrailingZeros

source · line 147
public
public fun stripTrailingZeros(): BigDecimal

Removes decimal coefficient zeros; zero becomes ZERO, and an unrepresentable nonzero scale throws.

function toShort

source · line 161
public
public fun toShort(): Short

Truncates toward zero and retains the target integer's low bits.

function toUInt

source · line 181
public
public fun toUInt(): UInt

Truncates toward zero and retains the target integer's low bits.

function toUShort

source · line 177
public
public fun toUShort(): UShort

Truncates toward zero and retains the target integer's low bits.

function toDouble

source · line 155
public
public fun toDouble(): Double

Rounds directly to binary64, allowing infinity and signed underflow zero.

property scale

source · line 10
public
public val scale: Long

get: public read-only

The decimal scale; negative scales represent integer powers of ten.

function toUIntExact

source · line 183
public
public fun toUIntExact(): UInt

Requires both an integral value and a representable UInt; otherwise throws ArithmeticException.

function toLongExact

source · line 171
public
public fun toLongExact(): Long

Requires both an integral value and a representable Long; otherwise throws ArithmeticException.

function toBigIntegerExact

source · line 151
public
public fun toBigIntegerExact(): BigInteger

Converts only if there is no fractional part; otherwise throws ArithmeticException.

function toString

source · line 42
public
public override fun toString(): String

Returns the canonical decimal text, preserving the coefficient and scale on parsing.

function toUByte

source · line 173
public
public fun toUByte(): UByte

Truncates toward zero and retains the target integer's low bits.

function toByte

source · line 157
public
public fun toByte(): Byte

Truncates toward zero and retains the target integer's low bits.

function toPlainString

source · line 44
public
public fun toPlainString(): String

Formats without an exponent; parsing preserves the numeric value.

function toULong

source · line 185
public
public fun toULong(): ULong

Truncates toward zero and retains the target integer's low bits.

function toInt

source · line 165
public
public fun toInt(): Int

Truncates toward zero and retains the target integer's low bits.

function hash

source · line 38
public
public override fun hash(): Long

Hashes the mathematical value, consistently across all equivalent representations.

function toLong

source · line 169
public
public fun toLong(): Long

Truncates toward zero and retains the target integer's low bits.

function precision

source · line 30
public
public fun precision(): Long

Returns the coefficient's decimal digit count, with precision one for zero.

function dec

source · line 65
public
public override operator fun dec(): BigDecimal

Returns this value minus the scale-zero constant one.