Posit numbers are an alternative to floating-point numbers. Posits extend floats by introducing regime bits, that allow for a higher precision around one, yet a wide dynamic range of representable numbers. For further information see https://posithub.org
If this library doesn't support a desired functionality or for anything else, please raise an issue.
8, 16 and 32bit posit formats
SoftPosit.jl emulates the following Posit number formats
n number of bits including
es exponent bits: Posit(8,0), Posit(16,1), Posit(32,2) as primitive types called
Posit8, Posit16, Posit32
following the draft standard. Additionally, the following off-standard formats are defined as primitive types, which are internally stored as 32bit (the remaining bits are kept as zeros): Posit(8,1), Posit(8,2), Posit(16,1), Posit(16,2), Posit(24,1), and Posit(24,2) called
For all the types
Posit8, Posit16, Posit32, Posit8_2, Posit16_2, Posit24_2 conversions between Integers and Floats and basic arithmetic operations
sqrt (among others) are defined. Unfortunately,
Posit8_1, Posit16_1, Posit24_1 are not yet fully supported by the underlying C library.
To support quires,
Quire32 are implemented as 32 / 128 / 512bit types for fused multiply-add and fused multiply-subtract. Additional math functions like
tan are defined via conversion to
Float64 (no support yet of the C library) and therefore do not have error-free rounding.
Conversion to and from
Float64 and computing a square root
julia> using SoftPosit julia> p = Posit16(16.0) Posit16(0x7000) julia> sqrt(p) Posit16(0x6000) julia> Float64(sqrt(p)) 4.0
for a comprehensive notebook covering (almost) all the functionality of SoftPosit.jl please read softposit_examples.ipynb
In the package manager do
julia>] add SoftPosit
and then simply
using SoftPosit which enables all of the functionality.