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

Functions

template<class T>
static constexpr unsigned int count_leading_zeros (const T num)

Function Documentation

◆ count_leading_zeros()

template<class T>
constexpr unsigned int FloatingPointHelpers::LeadingZerosPortability::count_leading_zeros ( const T num)
inlinestaticconstexpr

Definition at line 76 of file FPHelpers.h.

81 {
82 T probe = T(1) << (sizeof(T) * CHAR_BIT - 1);
83 unsigned int ret = 0;
84 while ((num & probe) == 0 && probe)
85 {
86 ++ret;
87 probe >>= 1;
88 }
89 return ret;
90 }