Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::universal::bisection_detail Namespace Reference

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.

Function Documentation

◆ bit_mask()

template<typename B>
B sw::universal::bisection_detail::bit_mask ( unsigned pos)
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.

◆ bit_test()

template<typename B>
bool sw::universal::bisection_detail::bit_test ( const B & v,
unsigned pos )
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.

◆ nan_encoding()

template<typename B>
B sw::universal::bisection_detail::nan_encoding ( unsigned p)
inline

NaN sentinel: the minimum signed value for a p-bit two's complement integer (1000...0 pattern).

◆ negate_bits()

template<typename B>
B sw::universal::bisection_detail::negate_bits ( const B & v)
inline

Two's complement negation.

◆ sign_extend()

template<typename B>
void sw::universal::bisection_detail::sign_extend ( B & y,
unsigned p )
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.