Skip to content

Posit v1 (Legacy): Original Reference Implementation

The posit v1 implementation (posit1) is the original reference implementation of John Gustafson’s posit arithmetic, dating to ~2017. It is maintained for backward compatibility and is the only posit implementation that provides full quire (super-accumulator) support with fused dot product (FDP) operations.

If you are starting a new project, use posit<nbits, es, bt> (the current v2 implementation). Use posit1 only if you need:

  • Compatibility with code written against the original posit API
  • The original quire implementation with full FDP support
  • Specialized posit configurations (posit_2_0, posit_3_0, etc.)

posit<nbits, es> (in the posit1 namespace) is the original two-parameter posit:

ParameterTypeDescription
nbitsunsignedTotal bits
esunsignedMaximum exponent bits

Note: unlike the current posit (v2), posit1 does not have a BlockType template parameter. It uses bitblock<> internally with uint64_t storage.

FeaturePosit v1 (posit1)Posit v2 (posit)
Template params2: nbits, es3: nbits, es, bt
Internal storagebitblock<> (legacy)blockbinary<> (modern)
Arithmetic engineinternal::value<>blocktriple<>
Block typeFixed uint64_tConfigurable (uint8_t-uint64_t)
QuireFull supportBridge header available
StatusLegacy/maintenanceActive development

The quire is the distinguishing feature of posit1:

template<unsigned nbits, unsigned es, unsigned capacity = 2>
class quire;

The quire is a fixed-point accumulator wide enough to hold the exact sum of any number of posit products without intermediate rounding. For posit<32, 2>, the quire is approximately 512 bits wide.

#include <universal/number/posit1/posit1.hpp>
using namespace sw::universal;
using Posit = posit<32, 2>;
using Quire = quire<32, 2>;
std::vector<Posit> a = { Posit(1.0), Posit(2.0), Posit(3.0) };
std::vector<Posit> b = { Posit(4.0), Posit(5.0), Posit(6.0) };
Quire q;
q.clear();
for (size_t i = 0; i < a.size(); ++i) {
q += quire_mul(a[i], b[i]); // Exact: no intermediate rounding
}
Posit result;
convert(q.to_value(), result);
// result = 32.0 exactly (1*4 + 2*5 + 3*6)
// fdp: fused dot product -- accumulate in quire, round once at the end
Posit fdp_result = fdp(a, b); // Equivalent to quire-based accumulation
Use CaseRecommendation
New project, general posit arithmeticUse posit (v2)
Need configurable block type for hardwareUse posit (v2)
Need full quire/FDP supportUse posit1
Backward compatibility with existing codeUse posit1
Reproducible linear algebra (BLAS)Use posit1 with quire
Mixed-precision algorithm explorationUse posit (v2)