<commit_before>///
/// @file   imath.hpp
/// @brief  Auxiliary integer math functions needed in primesieve.
///
/// Copyright (C) 2013 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#ifndef IMATH_PRIMESIEVE_HPP
#define IMATH_PRIMESIEVE_HPP

namespace soe {

template <typename T>
inline T numberOfBits(T)
{
  return static_cast<T>(sizeof(T) * 8);
}

template <typename T>
inline T isquare(T x)
{
  return x * x;
}

/// @brief  Check if an integer is a power of 2.
/// @see    Book "Hacker's Delight".
///
template <typename T>
inline bool isPowerOf2(T x)
{
  return (x != 0 && (x & (x - 1)) == 0);
}

/// @brief  Round down to the next power of 2.
/// @see    Book "Hacker's Delight".
///
template <typename T>
inline T floorPowerOf2(T x)
{<commit_msg>Refactoring<commit_after>///
/// @file   imath.hpp
/// @brief  Auxiliary integer math functions needed in primesieve.
///
/// Copyright (C) 2013 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#ifndef IMATH_HPP
#define IMATH_HPP

namespace soe {

template <typename T>
inline T numberOfBits(T)
{
  return static_cast<T>(sizeof(T) * 8);
}

template <typename T>
inline T isquare(T x)
{
  return x * x;
}

/// @brief  Check if an integer is a power of 2.
/// @see    Book "Hacker's Delight".
///
template <typename T>
inline bool isPowerOf2(T x)
{
  return (x != 0 && (x & (x - 1)) == 0);
}

/// @brief  Round down to the next power of 2.
/// @see    Book "Hacker's Delight".
///
template <typename T>
inline T floorPowerOf2(T x)
{
{'fraction_non_alphanumeric': 0.15515151515151515, 'fraction_numerical': 0.014545454545454545, 'mean_word_length': 2.9030732860520096, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6119144', 'n_tokens_mistral': 609, 'n_tokens_neox': 580, 'n_words': 212}