jaulib v1.4.0-2-g788cf73
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
Integer types and arithmetic

Integral integer types and arithmetic. More...

Namespaces

namespace  jau::int_literals
 

Classes

class  jau::mp::BigInt
 Arbitrary precision integer type. More...
 
struct  jau::float_bytes< bytesize >
 
struct  jau::float_bytes< sizeof(double)>
 
struct  jau::float_bytes< sizeof(float)>
 
struct  jau::float_bytes< sizeof(long double)>
 
class  jau::int_ctti
 
struct  jau::sint_bytes< bytesize >
 
struct  jau::sint_bytes< 4 >
 
struct  jau::sint_bytes< 8 >
 
struct  jau::uint128dp_t
 A 128-bit packed uint8_t data array. More...
 
struct  jau::uint192dp_t
 A 196-bit packed uint8_t data array. More...
 
struct  jau::uint256dp_t
 A 256-bit packed uint8_t data array. More...
 
struct  jau::uint_bytes< bytesize >
 
struct  jau::uint_bytes< 4 >
 
struct  jau::uint_bytes< 8 >
 

Typedefs

template<int bytesize>
using jau::float_bytes_t = typename float_bytes<bytesize>::type
 Alias template for float_bytes.
 
typedef uint_fast32_t jau::nsize_t
 Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
 
template<int bytesize>
using jau::sint_bytes_t = typename sint_bytes<bytesize>::type
 Alias template for sint_bytes.
 
typedef int_fast32_t jau::snsize_t
 Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
 
template<int bytesize>
using jau::uint_bytes_t = typename uint_bytes<bytesize>::type
 Alias template for uint_bytes.
 

Functions

mp::BigInt jau::abs (const mp::BigInt &x) noexcept
 
template<jau::req::signed_arithmetic T>
constexpr T jau::abs (const T x) noexcept
 Returns the absolute value of an arithmetic number (w/ branching) in O(1)
 
template<std::integral T>
constexpr bool jau::add_overflow (const T a, const T b, T &res) noexcept
 Integer overflow aware addition returning true if overflow occurred, otherwise false having the result stored in res.
 
template<jau::req::unsigned_integral T>
constexpr T jau::bit_ceil (const T n) noexcept
 If the given n is not is_power_of_2() return next_power_of_2(), otherwise return n unchanged.
 
template<jau::req::unsigned_integral T>
constexpr size_t jau::bit_count (T n) noexcept
 Returns the number of set bits within given unsigned integral.
 
const mp::BigIntjau::clamp (const mp::BigInt &x, const mp::BigInt &min_val, const mp::BigInt &max_val) noexcept
 
template<jau::req::arithmetic T>
constexpr T jau::clamp (const T x, const T min_val, const T max_val) noexcept
 Returns constrained integral value to lie between given min- and maximum value (w/ branching) in O(1).
 
mp::BigIntjau::clamp (mp::BigInt &x, mp::BigInt &min_val, mp::BigInt &max_val) noexcept
 
void jau::clear_bit_uint32 (const uint8_t nr, uint32_t &mask)
 
void jau::clear_bit_uint64 (const uint8_t nr, uint64_t &mask)
 
template<jau::req::unsigned_integral T>
constexpr size_t jau::digits (const T x, const nsize_t radix) noexcept
 Returns the number of digits of the given unsigned integral value number and the given radix.
 
template<std::integral T>
constexpr size_t jau::digits10 (const T x, const bool sign_is_digit=true) noexcept
 Returns the number of decimal digits of the given integral value number using std::log10<T>().
 
template<std::integral T>
constexpr size_t jau::digits10 (const T x, const snsize_t x_sign, const bool sign_is_digit=true) noexcept
 Returns the number of decimal digits of the given integral value number using std::log10<T>().
 
template<std::integral T>
constexpr bool jau::equals (const T &a, const T &b) noexcept
 Returns true if both values are equal.
 
mp::BigInt jau::gcd (const mp::BigInt &a, const mp::BigInt &b) noexcept
 
template<jau::req::signed_integral T>
constexpr T jau::gcd (T a, T b) noexcept
 Returns the greatest common divisor (GCD) of the two given integer values following Euclid's algorithm from Euclid's Elements ~300 BC, using the absolute positive value of given integers.
 
consteval_cxx20 bool jau::has_builtin_add_overflow () noexcept
 Query whether __builtin_add_overflow is available via __has_builtin(__builtin_add_overflow).
 
consteval_cxx20 bool jau::has_builtin_mul_overflow () noexcept
 Query whether __builtin_mul_overflow is available via __has_builtin(__builtin_mul_overflow).
 
consteval_cxx20 bool jau::has_builtin_sub_overflow () noexcept
 Query whether __builtin_sub_overflow is available via __has_builtin(__builtin_sub_overflow).
 
template<jau::req::unsigned_integral T>
constexpr nsize_t jau::high_bit (T x)
 Return the index of the highest set bit w/ branching (loop) in O(n/2).
 
template<jau::req::arithmetic T>
bool jau::in_range (const T &a, const T &b, const T &range)
 base_math: arithmetic types, i.e.
 
template<jau::req::signed_arithmetic T>
constexpr T jau::invert_sign (const T x) noexcept
 Safely inverts the sign of an arithmetic number w/ branching in O(1)
 
template<jau::req::unsigned_integral T>
constexpr bool jau::is_power_of_2 (const T x) noexcept
 Power of 2 test in O(1), i.e.
 
template<std::integral T>
constexpr bool jau::is_zero (const T &a) noexcept
 base_math: arithmetic types, i.e.
 
template<std::integral T>
constexpr bool jau::lcm_overflow (const T a, const T b, T &result) noexcept
 Integer overflow aware calculation of least common multiple (LCM) following Euclid's algorithm from Euclid's Elements ~300 BC.
 
constexpr size_t jau::log2_byteshift (const size_t bytesize) noexcept
 Returns log2(bytesize*8), e.g.
 
const mp::BigIntjau::max (const mp::BigInt &x, const mp::BigInt &y) noexcept
 
template<jau::req::arithmetic T>
constexpr T jau::max (const T x, const T y) noexcept
 Returns the maximum of two integrals (w/ branching) in O(1)
 
mp::BigIntjau::max (mp::BigInt &x, mp::BigInt &y) noexcept
 
uint128dp_t jau::merge_uint128 (uint16_t const uuid16, uint128dp_t const &base_uuid, nsize_t const uuid16_le_octet_index)
 Merge the given 'uuid16' into a 'base_uuid' copy at the given little endian 'uuid16_le_octet_index' position.
 
uint128dp_t jau::merge_uint128 (uint32_t const uuid32, uint128dp_t const &base_uuid, nsize_t const uuid32_le_octet_index)
 Merge the given 'uuid32' into a 'base_uuid' copy at the given little endian 'uuid32_le_octet_index' position.
 
const mp::BigIntjau::min (const mp::BigInt &x, const mp::BigInt &y) noexcept
 
template<jau::req::arithmetic T>
constexpr T jau::min (const T x, const T y) noexcept
 Returns the minimum of two integrals (w/ branching) in O(1)
 
mp::BigIntjau::min (mp::BigInt &x, mp::BigInt &y) noexcept
 
template<std::integral T>
constexpr bool jau::mul_overflow (const T a, const T b, T &res) noexcept
 Integer overflow aware multiplication returning true if overflow occurred, otherwise false having the result stored in res.
 
mp::BigInt jau::pow (mp::BigInt b, const mp::BigInt &e)
 
template<jau::req::unsigned_integral T, jau::req::unsigned_integral U>
constexpr T jau::round_down (T n, U align_to)
 Round down w/ branching in O(1)
 
template<jau::req::unsigned_integral T, jau::req::unsigned_integral U>
constexpr T jau::round_up (const T n, const U align_to)
 Round up w/ branching in O(1)
 
void jau::set_bit_uint32 (const uint8_t nr, uint32_t &mask)
 
void jau::set_bit_uint64 (const uint8_t nr, uint64_t &mask)
 
template<jau::req::signed_arithmetic T>
constexpr int jau::sign (const T x) noexcept
 Returns the value of the sign function (w/o branching ?) in O(1).
 
template<std::integral T>
constexpr bool jau::sub_overflow (const T a, const T b, T &res) noexcept
 Integer overflow aware subtraction returning true if overflow occurred, otherwise false having the result stored in res.
 
uint32_t jau::test_bit_uint32 (const uint8_t nr, const uint32_t mask)
 
uint64_t jau::test_bit_uint64 (const uint8_t nr, const uint64_t mask)
 

Detailed Description

Integral integer types and arithmetic.

Further support is coming from Byte Utilities and meta-group Math Support

Typedef Documentation

◆ nsize_t

typedef uint_fast32_t jau::nsize_t

Natural 'size_t' alternative using uint_fast32_t as its natural sized type.

The leading 'n' stands for natural.

This is a compromise to indicate intend, but to avoid handling a multiple sized size_t footprint where not desired.

Examples
test_lfringbuffer11.cpp.

Definition at line 55 of file int_types.hpp.

◆ snsize_t

typedef int_fast32_t jau::snsize_t

Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.

The leading 'n' stands for natural.

This is a compromise to indicate intend, but to avoid handling a multiple sized ssize_t footprint where not desired.

Definition at line 67 of file int_types.hpp.

◆ uint_bytes_t

template<int bytesize>
using jau::uint_bytes_t = typename uint_bytes<bytesize>::type

Alias template for uint_bytes.

Definition at line 79 of file int_types.hpp.

◆ sint_bytes_t

template<int bytesize>
using jau::sint_bytes_t = typename sint_bytes<bytesize>::type

Alias template for sint_bytes.

Definition at line 89 of file int_types.hpp.

◆ float_bytes_t

template<int bytesize>
using jau::float_bytes_t = typename float_bytes<bytesize>::type

Alias template for float_bytes.

Definition at line 97 of file int_types.hpp.

Function Documentation

◆ in_range()

template<jau::req::arithmetic T>
bool jau::in_range ( const T & a,
const T & b,
const T & range )

base_math: arithmetic types, i.e.

integral + floating point types int_math: integral types float_math: floating point types Returns true, if both integer point values differ less than the given range.

Template Parameters
Tan arithmetic type
Parameters
avalue to compare
bvalue to compare
rangethe maximum difference both values may differ

Definition at line 61 of file base_math.hpp.

◆ sign()

int jau::sign ( const T x)
constexprnoexcept

Returns the value of the sign function (w/o branching ?) in O(1).

-1 for x < 0
 0 for x = 0
 1 for x > 0

Implementation is type safe.

Branching may occur due to relational operator.

Template Parameters
Tan arithmetic number type
Parameters
xthe arithmetic number
Returns
function result

Definition at line 81 of file base_math.hpp.

Here is the caller graph for this function:

◆ invert_sign()

T jau::invert_sign ( const T x)
constexprnoexcept

Safely inverts the sign of an arithmetic number w/ branching in O(1)

Implementation takes special care to have T_MIN, i.e. std::numeric_limits<T>::min(), converted to T_MAX, i.e. std::numeric_limits<T>::max().
This is necessary since T_MAX < | -T_MIN | and the result would not fit in the return type T otherwise.

Hence for the extreme minimum case:

jau::invert_sign<int32_t>(INT32_MIN) = | INT32_MIN | - 1 = INT32_MAX

Otherwise with x < 0:

jau::invert_sign<int32_t>(x) = | x | = -x

and x >= 0:

jau::invert_sign<int32_t>(x) = -x
Template Parameters
Tan unsigned arithmetic number type
Parameters
xthe number
Returns
function result

Definition at line 119 of file base_math.hpp.

Here is the caller graph for this function:

◆ abs() [1/2]

T jau::abs ( const T x)
constexprnoexcept

Returns the absolute value of an arithmetic number (w/ branching) in O(1)

  • signed uses jau::invert_sign() to have a safe absolute value conversion
  • unsigned just returns the value
  • 2-complement branch-less is not used due to lack of INT_MIN -> INT_MAX conversion, bithacks Integer-Abs

This implementation uses jau::invert_sign() to have a safe absolute value conversion, if required.

Template Parameters
Tan arithmetic number type
Parameters
xthe number
Returns
function result

Definition at line 144 of file base_math.hpp.

Here is the caller graph for this function:

◆ min() [1/3]

template<jau::req::arithmetic T>
T jau::min ( const T x,
const T y )
constexprnoexcept

Returns the minimum of two integrals (w/ branching) in O(1)

Template Parameters
Tan arithmetic number type
Parameters
xone number
xthe other number

Definition at line 163 of file base_math.hpp.

Here is the caller graph for this function:

◆ max() [1/3]

template<jau::req::arithmetic T>
T jau::max ( const T x,
const T y )
constexprnoexcept

Returns the maximum of two integrals (w/ branching) in O(1)

Template Parameters
Tan arithmetic number type
Parameters
xone number
xthe other number

Definition at line 176 of file base_math.hpp.

Here is the caller graph for this function:

◆ clamp() [1/3]

template<jau::req::arithmetic T>
T jau::clamp ( const T x,
const T min_val,
const T max_val )
constexprnoexcept

Returns constrained integral value to lie between given min- and maximum value (w/ branching) in O(1).

Implementation returns min(max(x, min_val), max_val), analog to GLSL's clamp()

Template Parameters
Tan arithmetic number type
Parameters
xone number
min_valthe minimum limes, inclusive
max_valthe maximum limes, inclusive

Definition at line 192 of file base_math.hpp.

Here is the caller graph for this function:

◆ set_bit_uint32()

void jau::set_bit_uint32 ( const uint8_t nr,
uint32_t & mask )
inline

Definition at line 608 of file basic_types.hpp.

◆ clear_bit_uint32()

void jau::clear_bit_uint32 ( const uint8_t nr,
uint32_t & mask )
inline

Definition at line 614 of file basic_types.hpp.

◆ test_bit_uint32()

uint32_t jau::test_bit_uint32 ( const uint8_t nr,
const uint32_t mask )
inline

Definition at line 620 of file basic_types.hpp.

◆ set_bit_uint64()

void jau::set_bit_uint64 ( const uint8_t nr,
uint64_t & mask )
inline

Definition at line 626 of file basic_types.hpp.

◆ clear_bit_uint64()

void jau::clear_bit_uint64 ( const uint8_t nr,
uint64_t & mask )
inline

Definition at line 632 of file basic_types.hpp.

◆ test_bit_uint64()

uint64_t jau::test_bit_uint64 ( const uint8_t nr,
const uint64_t mask )
inline

Definition at line 638 of file basic_types.hpp.

◆ merge_uint128() [1/2]

uint128dp_t jau::merge_uint128 ( uint16_t const uuid16,
uint128dp_t const & base_uuid,
nsize_t const uuid16_le_octet_index )

Merge the given 'uuid16' into a 'base_uuid' copy at the given little endian 'uuid16_le_octet_index' position.

The given 'uuid16' value will be added with the 'base_uuid' copy at the given position.

base_uuid: 00000000-0000-1000-8000-00805F9B34FB
   uuid16: DCBA
uuid16_le_octet_index: 12
   result: 0000DCBA-0000-1000-8000-00805F9B34FB

LE: low-mem - FB349B5F8000-0080-0010-0000-ABCD0000 - high-mem
                                          ^ index 12
LE: uuid16 -> value.data[12+13]

BE: low-mem - 0000DCBA-0000-1000-8000-00805F9B34FB - high-mem
                  ^ index 2
BE: uuid16 -> value.data[2+3]

Definition at line 491 of file basic_types.cpp.

◆ merge_uint128() [2/2]

uint128dp_t jau::merge_uint128 ( uint32_t const uuid32,
uint128dp_t const & base_uuid,
nsize_t const uuid32_le_octet_index )

Merge the given 'uuid32' into a 'base_uuid' copy at the given little endian 'uuid32_le_octet_index' position.

The given 'uuid32' value will be added with the 'base_uuid' copy at the given position.

base_uuid: 00000000-0000-1000-8000-00805F9B34FB
   uuid32: 87654321
uuid32_le_octet_index: 12
   result: 87654321-0000-1000-8000-00805F9B34FB

LE: low-mem - FB349B5F8000-0080-0010-0000-12345678 - high-mem
                                          ^ index 12
LE: uuid32 -> value.data[12..15]

BE: low-mem - 87654321-0000-1000-8000-00805F9B34FB - high-mem
              ^ index 0
BE: uuid32 -> value.data[0..3]

Definition at line 525 of file basic_types.cpp.

◆ is_zero()

template<std::integral T>
bool jau::is_zero ( const T & a)
constexprnoexcept

base_math: arithmetic types, i.e.

integral + floating point types int_math: integral types float_math: floating point types Returns true of the given integer value is zero.

Definition at line 57 of file int_math.hpp.

◆ equals()

template<std::integral T>
bool jau::equals ( const T & a,
const T & b )
constexprnoexcept

Returns true if both values are equal.

Template Parameters
Tan integral type
Parameters
avalue to compare
bvalue to compare

Definition at line 69 of file int_math.hpp.

◆ round_up()

T jau::round_up ( const T n,
const U align_to )
constexpr

Round up w/ branching in O(1)

Template Parameters
Tan unsigned integral number type
Uan unsigned integral number type
Parameters
nto be aligned number
align_toalignment boundary, must not be 0
Returns
n rounded up to a multiple of align_to

Definition at line 96 of file int_math.hpp.

Here is the caller graph for this function:

◆ round_down()

T jau::round_down ( T n,
U align_to )
constexpr

Round down w/ branching in O(1)

Template Parameters
Tan unsigned integral number type
Uan unsigned integral number type
Parameters
nto be aligned number
align_toalignment boundary
Returns
n rounded down to a multiple of align_to

Definition at line 116 of file int_math.hpp.

Here is the caller graph for this function:

◆ is_power_of_2()

bool jau::is_power_of_2 ( const T x)
constexprnoexcept

Power of 2 test in O(1), i.e.

test whether a single bit is set

Uses either

Template Parameters
Tan unsigned integral number type
Parameters
xthe unsigned integral number
Returns
true if arg is 2^n for some x > 0
See also
std::has_single_bit()

Definition at line 134 of file int_math.hpp.

Here is the caller graph for this function:

◆ log2_byteshift()

size_t jau::log2_byteshift ( const size_t bytesize)
constexprnoexcept

Returns log2(bytesize*8), e.g.

to bit-shift whole byte values

If bytesize is not of power2, zero is returned.

Parameters
bytesizenumber of bytes
Returns
log2(bytesize*8)

Definition at line 150 of file int_math.hpp.

Here is the caller graph for this function:

◆ bit_ceil()

T jau::bit_ceil ( const T n)
constexprnoexcept

If the given n is not is_power_of_2() return next_power_of_2(), otherwise return n unchanged.

Uses either

  • C++20: std::bit_ceil
  • else: is_power_of_2 and ct_next_power_of_2
See also
std::bit_ceil()

Definition at line 186 of file int_math.hpp.

Here is the caller graph for this function:

◆ high_bit()

nsize_t jau::high_bit ( T x)
constexpr

Return the index of the highest set bit w/ branching (loop) in O(n/2).

Template Parameters
Tan unsigned integral number type
Parameters
xvalue

Definition at line 203 of file int_math.hpp.

Here is the caller graph for this function:

◆ bit_count()

size_t jau::bit_count ( T n)
constexprnoexcept

Returns the number of set bits within given unsigned integral.

Template Parameters
Tan unsigned integral number type
Parameters
nvalue

Definition at line 220 of file int_math.hpp.

Here is the caller graph for this function:

◆ has_builtin_add_overflow()

consteval_cxx20 bool jau::has_builtin_add_overflow ( )
noexcept

Query whether __builtin_add_overflow is available via __has_builtin(__builtin_add_overflow).

Definition at line 228 of file int_math.hpp.

Here is the caller graph for this function:

◆ has_builtin_sub_overflow()

consteval_cxx20 bool jau::has_builtin_sub_overflow ( )
noexcept

Query whether __builtin_sub_overflow is available via __has_builtin(__builtin_sub_overflow).

Definition at line 239 of file int_math.hpp.

Here is the caller graph for this function:

◆ has_builtin_mul_overflow()

consteval_cxx20 bool jau::has_builtin_mul_overflow ( )
noexcept

Query whether __builtin_mul_overflow is available via __has_builtin(__builtin_mul_overflow).

Definition at line 250 of file int_math.hpp.

Here is the caller graph for this function:

◆ add_overflow()

template<std::integral T>
bool jau::add_overflow ( const T a,
const T b,
T & res )
constexprnoexcept

Integer overflow aware addition returning true if overflow occurred, otherwise false having the result stored in res.

Implementation uses Integer Overflow Builtins if available, otherwise its own implementation.

Template Parameters
Tan integral integer type

param a operand a

Parameters
boperand b
resstorage for result
Returns
true if overflow, otherwise false

Definition at line 273 of file int_math.hpp.

Here is the caller graph for this function:

◆ sub_overflow()

template<std::integral T>
bool jau::sub_overflow ( const T a,
const T b,
T & res )
constexprnoexcept

Integer overflow aware subtraction returning true if overflow occurred, otherwise false having the result stored in res.

Implementation uses Integer Overflow Builtins if available, otherwise its own implementation.

Template Parameters
Tan integral integer type

param a operand a

Parameters
boperand b
resstorage for result
Returns
true if overflow, otherwise false

Definition at line 304 of file int_math.hpp.

Here is the caller graph for this function:

◆ mul_overflow()

template<std::integral T>
bool jau::mul_overflow ( const T a,
const T b,
T & res )
constexprnoexcept

Integer overflow aware multiplication returning true if overflow occurred, otherwise false having the result stored in res.

Implementation uses Integer Overflow Builtins if available, otherwise its own implementation.

Template Parameters
Tan integral integer type

param a operand a

Parameters
boperand b
resstorage for result
Returns
true if overflow, otherwise false

Definition at line 335 of file int_math.hpp.

Here is the caller graph for this function:

◆ gcd() [1/2]

T jau::gcd ( T a,
T b )
constexprnoexcept

Returns the greatest common divisor (GCD) of the two given integer values following Euclid's algorithm from Euclid's Elements ~300 BC, using the absolute positive value of given integers.

Returns zero if a and b is zero.

Note implementation uses modulo operator (a/b)*b + a % b = a, i.e. remainder of the integer division - hence implementation uses abs(a) % abs(b) in case the integral T is a signed type (dropped for unsigned).

Implementation is similar to std::gcd(), however, it uses a fixed common type T and a while loop instead of compile time evaluation via recursion.

Template Parameters
Tintegral type

param a integral value a

Parameters
bintegral value b
Returns
zero if a and b are zero, otherwise the greatest common divisor (GCD) of a and b,

Definition at line 370 of file int_math.hpp.

Here is the caller graph for this function:

◆ lcm_overflow()

template<std::integral T>
bool jau::lcm_overflow ( const T a,
const T b,
T & result )
constexprnoexcept

Integer overflow aware calculation of least common multiple (LCM) following Euclid's algorithm from Euclid's Elements ~300 BC.

Template Parameters
Tintegral type

param result storage for lcm result: zero if a and b are zero, otherwise lcm of a and b

Parameters
aintegral value a
bintegral value b
Returns
true if overflow, otherwise false for success

Definition at line 401 of file int_math.hpp.

Here is the caller graph for this function:

◆ digits10() [1/2]

template<std::integral T>
size_t jau::digits10 ( const T x,
const snsize_t x_sign,
const bool sign_is_digit = true )
constexprnoexcept

Returns the number of decimal digits of the given integral value number using std::log10<T>().


If sign_is_digit == true (default), treats a potential negative sign as a digit.

x < 0: 1 + (int) ( log10( -x ) ) + ( sign_is_digit ? 1 : 0 )
x = 0: 1
x > 0: 1 + (int) ( log10(  x ) )

Implementation uses jau::invert_sign() to have a safe absolute value conversion, if required.

Convenience method, reusing precomputed sign of value to avoid redundant computations.

Template Parameters
Tan integral integer type
Parameters
xthe integral integer
x_signthe pre-determined sign of the given value x
sign_is_digitif true and value is negative, adds one to result for sign. Defaults to true.
Returns
digit count
Examples
test_intdecstring01.cpp.

Definition at line 436 of file int_math.hpp.

Here is the caller graph for this function:

◆ digits10() [2/2]

template<std::integral T>
size_t jau::digits10 ( const T x,
const bool sign_is_digit = true )
constexprnoexcept

Returns the number of decimal digits of the given integral value number using std::log10<T>().

If sign_is_digit == true (default), treats a potential negative sign as a digit.

x < 0: 1 + (int) ( log10( -x ) ) + ( sign_is_digit ? 1 : 0 )
x = 0: 1
x > 0: 1 + (int) ( log10(  x ) )

Implementation uses jau::invert_sign() to have a safe absolute value conversion, if required.

Template Parameters
Tan integral integer type
Parameters
xthe integral integer
sign_is_digitif true and value is negative, adds one to result for sign. Defaults to true.
Returns
digit count

Definition at line 462 of file int_math.hpp.

◆ digits()

size_t jau::digits ( const T x,
const nsize_t radix )
constexprnoexcept

Returns the number of digits of the given unsigned integral value number and the given radix.

Template Parameters
Tan integral unsigned integer type
Parameters
xthe integral integer
radixbase of the number system, e.g. 2 binary, 8 octal, 10 decimal, 16 hexadecimal, ..
Returns
digit count

Definition at line 476 of file int_math.hpp.

Here is the caller graph for this function:

◆ abs() [2/2]

mp::BigInt jau::abs ( const mp::BigInt & x)
inlinenoexcept

Definition at line 1565 of file big_int.hpp.

◆ pow()

mp::BigInt jau::pow ( mp::BigInt b,
const mp::BigInt & e )
inline

Definition at line 1566 of file big_int.hpp.

Here is the caller graph for this function:

◆ min() [2/3]

const mp::BigInt & jau::min ( const mp::BigInt & x,
const mp::BigInt & y )
inlinenoexcept

Definition at line 1568 of file big_int.hpp.

◆ max() [2/3]

const mp::BigInt & jau::max ( const mp::BigInt & x,
const mp::BigInt & y )
inlinenoexcept

Definition at line 1571 of file big_int.hpp.

◆ clamp() [2/3]

const mp::BigInt & jau::clamp ( const mp::BigInt & x,
const mp::BigInt & min_val,
const mp::BigInt & max_val )
inlinenoexcept

Definition at line 1574 of file big_int.hpp.

◆ min() [3/3]

mp::BigInt & jau::min ( mp::BigInt & x,
mp::BigInt & y )
inlinenoexcept

Definition at line 1578 of file big_int.hpp.

◆ max() [3/3]

mp::BigInt & jau::max ( mp::BigInt & x,
mp::BigInt & y )
inlinenoexcept

Definition at line 1581 of file big_int.hpp.

◆ clamp() [3/3]

mp::BigInt & jau::clamp ( mp::BigInt & x,
mp::BigInt & min_val,
mp::BigInt & max_val )
inlinenoexcept

Definition at line 1584 of file big_int.hpp.

◆ gcd() [2/2]

mp::BigInt jau::gcd ( const mp::BigInt & a,
const mp::BigInt & b )
inlinenoexcept

Definition at line 1588 of file big_int.hpp.