AsmGrader 0.0.0
Loading...
Searching...
No Matches
integer.hpp File Reference
#include <asmgrader/common/aliases.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/detail/mp_list.hpp>
#include <boost/mp11/integral.hpp>
#include <bit>
#include <cmath>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <type_traits>
Include dependency graph for integer.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  asmgrader
 
namespace  asmgrader::detail
 

Typedefs

using asmgrader::detail::sized_uint_map = mp::mp_list<u8, std::uint16_t, std::uint32_t, std::uint64_t>
 
using asmgrader::detail::sized_int_map = mp::mp_list<i8, std::int16_t, std::int32_t, std::int64_t>
 
template<std::size_t I>
using asmgrader::detail::sized_int_impl = mp::mp_at<sized_int_map, mp::mp_int<I>>
 
template<std::size_t I>
using asmgrader::detail::sized_uint_impl = mp::mp_at<sized_uint_map, mp::mp_int<I>>
 
template<std::size_t NumBits>
using asmgrader::sized_int_t = detail::sized_int_impl<std::bit_width(NumBits) - 1>
 
template<std::size_t NumBits>
using asmgrader::sized_uint_t = detail::sized_uint_impl<std::bit_width(NumBits) - 1>
 

Variables

template<typename IntType >
constexpr std::size_t asmgrader::digits10_max_count = std::numeric_limits<std::decay_t<IntType>>::digits10 + 1
 This was a little confusing (to me at least) digits10 => maximum number of base-10 digits that can be represented with IntType below is a definition for the inverse of that i.e. => maximmum number of base-10 digits that IntType can represent For both signed and unsigned integer types, the value that produces the maximal amount of base10 digits will never itself be a power of 10. The proof for this is trivial using parity to check when all bits are set [2^(n+1) - 1] and factorization to check 2^n (for the negative complement of signed min).