FixedPointDecimals.FixedDecimalType
FixedDecimal{T <: Integer, f::Int}

A fixed-point decimal type backed by integral type T, with f digits after the decimal point stored.

FixedPointDecimals._apply_exact_floatMethod
_apply_exact_float(f, T, x::Real, i::Integer)

Compute f(T, x, i)::T but avoiding possible loss of precision from an intermediate conversion of i to a floating point type by instead using a BigFloat with sufficient precision if necessary.

FixedPointDecimals._round_to_nearestMethod
_round_to_nearest(quotient, remainder, divisor, ::RoundingMode{M})

Round quotient + remainder / divisor to the nearest integer, given that 0 ≤ remainder < divisor or 0 ≥ remainder > divisor. (This assumption is satisfied by the return value of fldmod in all cases, and the return value of divrem in cases where divisor is known to be positive.) The tie is decided depending on the RoundingMode.

FixedPointDecimals.ceilmulFunction
ceilmul(I, x, y) :: I

Compute ceil(I, x * y), returning the result as type I. For floating point values, this function can be more accurate than ceil(x * y).

FixedPointDecimals.checked_rdivMethod
FixedPointDecimals.checked_rdiv(x::FD, y::FD) -> FD

Calculates x / y, checking for overflow errors where applicable.

The overflow protection may impose a perceptible performance penalty.

See also:

  • Base.checked_div for truncating division.
FixedPointDecimals.coefficientMethod
coefficient(::Type{FD{T, f}}) -> T

Compute 10^f as an Integer without overflow. Note that overflow will not occur for any constructable FD{T, f}.

FixedPointDecimals.floormulFunction
floormul(I, x, y) :: I

Compute floor(I, x * y), returning the result as type I. For floating point values, this function can be more accurate than floor(x * y).

FixedPointDecimals.max_exp10Method
max_exp10(T)

The highest value of x which does not result in an overflow when evaluating T(10)^x. For types of T that do not overflow -1 will be returned.

NOTE: This function is expensive, since it contains a while-loop, but it is actually computing a constant value for types, so it really only needs to be run once per type. We achieve this by @evaling new methods in a loop, below. Users can do this themselves to add more "frozen" methods for custom Integer types: julia @eval FixedPointDecimals.max_exp10(::Type{CustomIntType}) = $(max_exp10(CustomIntType)) This function does not have or depend on any side-effects.

FixedPointDecimals.required_precisionMethod
required_precision(n::Integer)

Compute the number of bits of precision needed to represent an integer exactly as a floating point number.

This is equivalent to counting the number of bits needed to represent the integer, excluding any trailing zeros.

FixedPointDecimals.truncmulFunction
truncmul(I, x, y) :: I

Compute trunc(I, x * y), returning the result as type I. For floating point values, this function can be more accurate than trunc(x * y).