41# define FZ_HOST_DEVICE __host__ __device__
43# define FZ_HOST_DEVICE
50 static_assert(std::is_integral<T>::value && std::is_signed<T>::value,
51 "fz::Negabinary<T>: T must be a signed integer type "
52 "(int8_t, int16_t, int32_t, or int64_t).");
55 using UInt =
typename std::make_unsigned<T>::type;
63 static constexpr UInt MASK =
64 static_cast<UInt
>(
static_cast<uint64_t
>(0xAAAAAAAAAAAAAAAAULL));
71 FZ_HOST_DEVICE
static constexpr UInt encode(SInt n)
noexcept {
72 return (
static_cast<UInt
>(n) + MASK) ^ MASK;
83 FZ_HOST_DEVICE
static constexpr SInt decode(UInt u)
noexcept {
84 return static_cast<SInt
>((u ^ MASK) - MASK);
91using Negabinary8 = Negabinary<int8_t>;
92using Negabinary16 = Negabinary<int16_t>;
93using Negabinary32 = Negabinary<int32_t>;
94using Negabinary64 = Negabinary<int64_t>;
Definition fzm_format.h:25