|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
INT | ts::abs (INT a) |
| Absolute value of integer types, also working on unsigned types.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
bool | ts::add_overflow (INT a, INT b) platform_specific |
| Check if an integer addition generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
bool | ts::add_overflow (INT a, INT b, INT res) |
| Check if an integer addition generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
size_t | ts::BitSize (INT x) |
| Get the size in bits of an integer value.
|
|
template<typename INT1 , typename INT2 , typename std::enable_if< std::is_integral< INT1 >::value &&std::is_integral< INT2 >::value, int >::type = 0> |
bool | ts::bound_check (INT2 x) |
| Integer cross-type bound check.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::bounded_add (INT a, INT b) |
| Perform a bounded addition without overflow.
|
|
template<typename INT1 , typename INT2 , typename std::enable_if< std::is_integral< INT1 >::value &&std::is_integral< INT2 >::value, int >::type = 0> |
INT1 | ts::bounded_cast (INT2 x) |
| Bounded integer cast.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::bounded_sub (INT a, INT b) |
| Perform a bounded subtraction without overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::debug_thow_neg_overflow (INT a) |
| In debug mode, throw an exception if the negation (opposite sign) of an integer generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::debug_throw_add_overflow (INT a, INT b, INT res) |
| In debug mode, throw an exception if an integer addition generates an overflow.
|
|
template<typename INT1 , typename INT2 , typename std::enable_if< std::is_integral< INT1 >::value &&std::is_integral< INT2 >::value, int >::type = 0> |
void | ts::debug_throw_bound_check (INT2 x) |
| In debug mode, throw an exception if an integer value does not fall into the range of another integer type.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::debug_throw_div_zero (INT den) |
| In debug mode, throw an exception if the denominator of an integer division is zero.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::debug_throw_mul_overflow (INT a, INT b, INT res) |
| In debug mode, throw an exception if an integer multiplication generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::debug_throw_sub_overflow (INT a, INT b, INT res) |
| In debug mode, throw an exception if an integer substraction generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::GCD (INT x, INT y) |
| Compute a greatest common denominator (GCD).
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
bool | ts::is_negative (INT a) |
| Check if an integer value is negative, optimized for signed or unsigned type.
|
|
size_t | ts::MaxDecimalWidth (size_t typeSize, size_t digitSeparatorSize=0) |
| Compute the maximum width of the decimal representation of an integer type.
|
|
size_t | ts::MaxHexaWidth (size_t typeSize, size_t digitSeparatorSize=0) |
| Compute the maximum width of the hexadecimal representation of an integer type.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
bool | ts::mul_overflow (INT a, INT b) platform_specific |
| Check if an integer multiplication generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
bool | ts::mul_overflow (INT a, INT b, INT res) |
| Check if an integer multiplication generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
bool | ts::neg_overflow (INT a) |
| Check if the negation (opposite sign) of an integer generates an overflow.
|
|
uint64_t | ts::Power10 (size_t pow) |
| Get a power of 10 using a fast lookup table.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::round_down (INT x, INT f) |
| Round x down to previous multiple of a factor f.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::round_up (INT x, INT f) |
| Round x up to next multiple of a factor f.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> |
INT | ts::rounded_div (INT a, INT b) |
| Integer division with rounding to closest value (instead of truncating).
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
void | ts::sign_reduce (INT &num, INT &den) |
| Reduce the sign of an integer fraction.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
const UChar * | ts::SignedDescription () |
| Get the signed/unsigned qualifier of an integer type as a string.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_signed< INT >::value >::type * = nullptr> |
INT | ts::SignExtend (INT x, size_t bits) |
| Perform a sign extension on any subset of a signed integer.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
bool | ts::sub_overflow (INT a, INT b) platform_specific |
| Check if an integer substraction generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value, int >::type = 0> |
bool | ts::sub_overflow (INT a, INT b, INT res) |
| Check if an integer substraction generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::thow_neg_overflow (INT a) |
| Throw an exception if the negation (opposite sign) of an integer generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::throw_add_overflow (INT a, INT b, INT res) |
| Throw an exception if an integer addition generates an overflow.
|
|
template<typename INT1 , typename INT2 , typename std::enable_if< std::is_integral< INT1 >::value &&std::is_integral< INT2 >::value, int >::type = 0> |
void | ts::throw_bound_check (INT2 x) |
| Throw an exception if an integer value does not fall into the range of another integer type.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::throw_div_zero (INT den) |
| Throw an exception if the denominator of an integer division is zero.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::throw_mul_overflow (INT a, INT b, INT res) |
| Throw an exception if an integer multiplication generates an overflow.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value, int >::type = 0> |
void | ts::throw_sub_overflow (INT a, INT b, INT res) |
| Throw an exception if an integer substraction generates an overflow.
|
|
Some utilities on integers.