A posit arithmetic emulator. Julia types for the C-based SoftPosit library.
Author milankl
19 Stars
Updated Last
2 Years Ago
Started In
April 2019

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Travis AppVeyor Cirrus CI



Julia types for the C-based SoftPosit library - a posit arithmetic emulator.

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

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 Posit(n,es), with 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 Posit8_1, Posit8_2, Posit16_1, Posit16_2, Posit24_1, and Posit24_2.

For all the types Posit8, Posit16, Posit32, Posit8_2, Posit16_2, Posit24_2 conversions between Integers and Floats and basic arithmetic operations +, -, *, / and 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, Quire8, Quire16 and Quire32 are implemented as 32 / 128 / 512bit types for fused multiply-add and fused multiply-subtract. Additional math functions like exp,log,sin,cos,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)

julia> sqrt(p)

julia> Float64(sqrt(p))

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.

Required Packages

Used By Packages

No packages found.