bitwise: add word halving query
This commit is contained in:
parent
8f5604dde6
commit
e1f18edacf
23
bitwise.hpp
23
bitwise.hpp
@ -149,6 +149,29 @@ namespace cruft {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace bits {
|
||||
inline constexpr std::tuple<u32, u32> halve (u64 val)
|
||||
{
|
||||
return { val >> 32, val & 0xffffffff };
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
inline constexpr std::tuple<u16, u16> halve (u32 val)
|
||||
{
|
||||
return { val >> 16, val & 0xffff };
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
inline constexpr std::tuple<u08, u08> halve (u16 val)
|
||||
{
|
||||
return { val >> 8, val & 0xff };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// returns the integral value composed of the bits from `val' in the
|
||||
/// inclusive range [lo, hi].
|
||||
|
Loading…
Reference in New Issue
Block a user