bigdecimal
Types
pub opaque type BigDecimal
Functions
pub fn absolute_value(of value: BigDecimal) -> BigDecimal
pub fn clamp(
value: BigDecimal,
min min: BigDecimal,
max max: BigDecimal,
) -> BigDecimal
N.B. if the input has equal value to either of the extremes but different precision, the larger precision will be returned
pub fn compare(this: BigDecimal, with that: BigDecimal) -> Order
N.B. If scale is different, trailing zeros are ignored.
pub fn divide(
dividend: BigDecimal,
by divisor: BigDecimal,
rounding rounding: RoundingMode,
) -> BigDecimal
Divide the dividend by the divisor.
The result has a preferred scale of scale(dividend) - scale(divisor)
,
but might have scale up to precision(dividend) + ceil(10 * precision(divisor) / 3)
.
pub fn from_float(value: Float) -> BigDecimal
pub fn from_string(value: String) -> Result(BigDecimal, Nil)
pub fn multiply(
multiplicand: BigDecimal,
with multiplier: BigDecimal,
) -> BigDecimal
pub fn power(
value: BigDecimal,
exponent: Int,
) -> Result(BigDecimal, Nil)
Returns an error if the exponent is negative.
(Inherited behaviour from bigi
)
pub fn precision(of value: BigDecimal) -> Int
The number of digits in the unscaled value.
pub fn product(values: List(BigDecimal)) -> BigDecimal
For an empty list, this will return one()
.
pub fn rescale(
value: BigDecimal,
scale new_scale: Int,
rounding rounding: RoundingMode,
) -> BigDecimal
pub fn signum(of value: BigDecimal) -> Int
Sign function. Returns +1 if the value is positive, -1 if the value is negative, 0 if the value is zero.
pub fn ulp(of value: BigDecimal) -> BigDecimal
Returns the unit of least precision of this BigDecimal
.
pub fn unscaled_value(of value: BigDecimal) -> BigInt