Julia fixed-point decimals built from integers
Author JuliaMath
7 Stars
Updated Last
10 Months Ago
Started In
May 2017


Travis Build Status Appveyor Build Status coveralls

Provides the fixed-point decimal type FixedDecimal allowing for exact representations of decimal numbers. These numbers are useful in financial calculations where interactions between decimal numbers are required to be exact.

This library defines the type FixedDecimal{T <: Integer, f} as a subtype of Real. The parameter T is the underlying machine representation and f is the number of decimal places which can be stored.

For example, FixedDecimal{Int8, 2} allows you to a decimal number with up to 2 fractional digits. All FixedDecimal{Int8, 2} numbers x must satisfy

-1.28 = -128/10² ≤ x ≤ 127/10² = 1.27

because the range of Int8 is from -128 to 127.

In general FixedDecimal{T <: Integer, f} numbers y must satisfy:

typemin(T)/10ᶠ ≤ y ≤ typemax(T)/10ᶠ


julia> using FixedPointDecimals

julia> 2.2 / 10

julia> FixedDecimal{Int,2}(2.2) / 10

julia> 0.1 + 0.2

julia> FixedDecimal{Int,1}(0.1) + FixedDecimal{Int,1}(0.2)

Required Packages

No packages found.

Used By Packages