|
Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
|
Functions | |
| template<typename B> | |
| B | bit_mask (unsigned pos) |
| Create a value of type B with exactly one bit set at position pos. | |
| template<typename B> | |
| bool | bit_test (const B &v, unsigned pos) |
| Read the bit at position pos in value v. | |
| template<typename B> | |
| void | sign_extend (B &y, unsigned p) |
| Sign-extend from p bits to the full width of B. | |
| template<typename B> | |
| B | nan_encoding (unsigned p) |
| NaN sentinel: the minimum signed value for a p-bit two's complement integer (1000...0 pattern). | |
| template<typename B> | |
| B | negate_bits (const B &v) |
| Two's complement negation. | |
|
inline |
Create a value of type B with exactly one bit set at position pos.
Uses uint64_t for the int64_t path to avoid UB from left-shifting into the sign bit when pos == 63.
|
inline |
Read the bit at position pos in value v.
Uses uint64_t cast for the int64_t path to avoid implementation-defined right-shift of signed values.
|
inline |
NaN sentinel: the minimum signed value for a p-bit two's complement integer (1000...0 pattern).
|
inline |
Two's complement negation.
|
inline |
Sign-extend from p bits to the full width of B.
For int64_t this is required when p < 64; for blockbinary it is a no-op because the storage is already exactly nbits wide.