ATLAS Offline Software
Loading...
Searching...
No Matches
FloatingPointHelpers::OperatorsHelper Namespace Reference

Functions

template<class T>
static constexpr T safe_lshift (const T x, const T amount)
template<class T>
static constexpr T safe_rshift (const T x, const T amount)
template<class T>
static constexpr T clamped_sub (const T x1, const T x2)
template<class T>
static constexpr T min (const T x1, const T x2)
template<class T>
static constexpr T max (const T x1, const T x2)
template<class T>
static constexpr T clamp (const T x, const T low, const T high)
template<class T>
static constexpr T bit_and (const T x1, const T x2)
template<class T>
static constexpr T bit_or (const T x1, const T x2)

Function Documentation

◆ bit_and()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::bit_and ( const T x1,
const T x2 )
inlinestaticconstexpr

Definition at line 245 of file FPHelpers.h.

246 {
247 return x1 & x2;
248 }

◆ bit_or()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::bit_or ( const T x1,
const T x2 )
inlinestaticconstexpr

Definition at line 251 of file FPHelpers.h.

252 {
253 return x1 | x2;
254 }

◆ clamp()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::clamp ( const T x,
const T low,
const T high )
inlinestaticconstexpr

Definition at line 237 of file FPHelpers.h.

238 {
239 return low * (x < low) + high * (x > high) + x * (x >= low && x <= high);
240 }
#define x

◆ clamped_sub()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::clamped_sub ( const T x1,
const T x2 )
inlinestaticconstexpr

Definition at line 219 of file FPHelpers.h.

220 {
221 return (x1 - x2) * (x1 >= x2);
222 }

◆ max()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::max ( const T x1,
const T x2 )
inlinestaticconstexpr

Definition at line 231 of file FPHelpers.h.

232 {
233 return (x1 > x2) * x1 + (x1 <= x2) * x2;
234 }

◆ min()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::min ( const T x1,
const T x2 )
inlinestaticconstexpr

Definition at line 225 of file FPHelpers.h.

226 {
227 return (x1 > x2) * x2 + (x1 <= x2) * x1;
228 }

◆ safe_lshift()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::safe_lshift ( const T x,
const T amount )
inlinestaticconstexpr

Definition at line 204 of file FPHelpers.h.

205 {
206 const bool valid = amount < sizeof(T) * CHAR_BIT;
207 return (x << (amount * valid)) * valid;
208 }

◆ safe_rshift()

template<class T>
constexpr T FloatingPointHelpers::OperatorsHelper::safe_rshift ( const T x,
const T amount )
inlinestaticconstexpr

Definition at line 211 of file FPHelpers.h.

212 {
213 const bool valid = amount < sizeof(T) * CHAR_BIT;
214 return (x >> (amount * valid)) * valid;
215 }