fixpnt<nbits, rbits>

Arbitrary, fixed-size, fixed-point real with overflow and arithmetic exceptions

fixpnt<nbits, rbits> is a 2's complement encoded arbitrary, fixed-size fixed-point type.

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

template<size_t nbits, size_t rbits, bool arithmetic = Modulo, typename bt = uint8_t>
class fixpnt;

The fixpnt type is parameterized in terms of the number of bits in a 2's complement encoding, the position of the radix bit, the type of arithmetic (Modulo vs Saturating), and the block type to use in the representation. The type will automatically allocate the minimum number of blocks to represent the fixpnt. Effectively, the size of the block type will define the memory alignment of fixpnt values in arrays and vectors.

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

#define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/fixpnt/fixpnt.hpp>

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

The fixpnt type is designed for applications that need fine-grain control over their quantization, such as digital signal processing and data acquisition applications. It can be used for digital twin models and verification of FPGA designs.

It can also be used as a super accumulator for accurate sums and dot products.

Last updated