posit<nbits, es>

Arbitrary, fixed-size, tapered floating-point with arithmetic exceptions

posit<nbits, es> is a tapered floating-point type of arbitrary, fixed size.

The type definition for arbitrary, fixed-size posits in Universal is:

template<size_t nbits, size_t es, typename BlockType = uint8_t>
class posit;

The posit type is parameterized in terms of the number of bits in the encoding, the number of exponent bits, and the block type to use in the representation. The type will automatically allocate the minimum number of blocks to represent the posit. Effectively, the size of the block type will define the memory alignment of posit values in arrays and vectors.

The posit type can be compiled with or without exceptions using a compile guard: POSIT_THROW_ARITHMETIC_EXCEPTION, to be set before including the type in your module, like so:

#define POSIT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/posit/posit.hpp>

By default, exceptions are not enabled. They are defined, but not thrown, so client code will work in either configuration.

Posits dynamically reallocate bits between scale and precision. Posits are symmetric and most precise around 1: a nbit posit will have (nbits - es - 3) fraction bits and always include the hidden bit. At the extreme scales, posits will have no fraction bits nor any exponent bits.

Fundamentally, posits are floating-point types. Just like IEEE-754, posits are susceptible to catastrophic cancellation. However, in contrast to IEEE-754, posits support the fused dot product through a super accumulator called the quire. The quire can be used more generally for user-deferred rounding and receives unrounded values from the arithmetic operations. This support of the fused dot product makes it possible to use much smaller posit configurations as compared to IEEE-754 and still yield the same accuracy. A 32 bit posit typically beats a double-precision IEEE-754 in precision. This makes posit algorithms much more memory and energy-efficient as compared to IEEE-754 floating-point.

Last updated