Scoop API

scoop:scoop.math:0.1.0

src/big_decimal/conversions.scoop

Selected production source · src/big_decimal/conversions.scoop

1package scoop.math
3/** Parses ASCII decimal text with optional e/E exponent, preserving trailing zeros. */
4public fun String.toBigDecimal(): BigDecimal = BigDecimal.parse(this)
5/** Returns None for malformed decimal text or an unrepresentable scale. */
6public fun String.toBigDecimalOrNone(): BigDecimal? = BigDecimal.parseOrNone(this)
7/** Shares this immutable integer as a decimal coefficient at scale zero. */
8public fun BigInteger.toBigDecimal(): BigDecimal = BigDecimal(this)
9/** Converts the mathematical integer exactly at scale zero. */
10public fun Byte.toBigDecimal(): BigDecimal = BigDecimal(toLong())
11/** Converts the mathematical integer exactly at scale zero. */
12public fun Short.toBigDecimal(): BigDecimal = BigDecimal(toLong())
13/** Converts the mathematical integer exactly at scale zero. */
14public fun Int.toBigDecimal(): BigDecimal = BigDecimal(toLong())
15/** Converts the mathematical integer exactly at scale zero. */
16public fun Long.toBigDecimal(): BigDecimal = BigDecimal(toLong())
17/** Converts the mathematical integer exactly at scale zero. */
18public fun UByte.toBigDecimal(): BigDecimal = BigDecimal(toULong())
19/** Converts the mathematical integer exactly at scale zero. */
20public fun UShort.toBigDecimal(): BigDecimal = BigDecimal(toULong())
21/** Converts the mathematical integer exactly at scale zero. */
22public fun UInt.toBigDecimal(): BigDecimal = BigDecimal(toULong())
23/** Converts the mathematical integer exactly at scale zero. */
24public fun ULong.toBigDecimal(): BigDecimal = BigDecimal(toULong())