<commit_before>#include <cassert>
#include <exception>
#include <string>

namespace batriz {
namespace integer {

// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
template <class T>
T next_power_of_2(T x) {
    --x;
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;
    ++x;
    return x;
}

// https://docs.python.org/3/library/stdtypes.html#int.bit_length
template <class T>
int bit_length(T x) {
    if (x < 0) {
        x = -x;
    }
    int len = 0;
    if (x >= (1 << 16) - 1) {
        x = x >> 16;
        len += 16;
    }
    if (x >= (1 << 8) - 1) {
        x = x >> 8;
        len += 8;
    }
    if (x >= (1 << 4) - 1) {
        x = x >> 4;
        len += 4;
    }
    if (x >= (1 << 2) - 1) {
        x = x >> 2;
        len += 2;
    }
    if (x >= (1 << 1) - 1) {
        x = x >> 1;
        len += 1;
    }
    if (x >= 1) {
        ++len;
    }
    return len;
}

struct OverflowError : public std::exception {};

enum class ByteOrder { Big, Little };<commit_msg>add bit_length()<commit_after>#include <cassert>
#include <exception>
#include <string>

namespace batriz {
namespace integer {

// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
template <class T>
T next_power_of_2(T x) {
    --x;
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;
    ++x;
    return x;
}

// https://docs.python.org/3/library/stdtypes.html#int.bit_length
template <class T>
int bit_length(T x) {
    if (x < 0) {
        x = -x;
    }
    int len = 0;
    if (x >= (1 << 16) - 1) {
        x = x >> 16;
        len += 16;
    }
    if (x >= (1 << 8) - 1) {
        x = x >> 8;
        len += 8;
    }
    if (x >= (1 << 4) - 1) {
        x = x >> 4;
        len += 4;
    }
    if (x >= (1 << 2) - 1) {
        x = x >> 2;
        len += 2;
    }
    if (x >= (1 << 1) - 1) {
        x = x >> 1;
        len += 1;
    }
    if (x >= 1) {
        ++len;
    }
    return len;
}

template <class T>
int leading_zeros(T x) {
    return bit_length(x & -x) - 1;
}

struct OverflowError : public std::exception {};

enum class ByteOrder { Big, Little };
{'fraction_non_alphanumeric': 0.19435446552521982, 'fraction_numerical': 0.037482646922720964, 'mean_word_length': 1.564650059311981, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 66, 'https://': 2, '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': '53405', 'n_tokens_mistral': 933, 'n_tokens_neox': 865, 'n_words': 243}