1#ifndef MSTL_CORE_NUMERIC_NUMERIC_TYPES_HPP__
2#define MSTL_CORE_NUMERIC_NUMERIC_TYPES_HPP__
32template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
33MSTL_CONST_FUNCTION
constexpr bool signbit(
const T x)
noexcept {
36 const UInt bits = *
reinterpret_cast<const UInt*
>(&x);
37 constexpr UInt sign_mask =
static_cast<UInt
>(1) << (8 *
sizeof(UInt) - 1);
38 return (bits & sign_mask) != 0;
50template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
51MSTL_CONST_FUNCTION
constexpr bool is_nan(
const T x)
noexcept {
61template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
72template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
84template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
85MSTL_CONST_FUNCTION
constexpr bool is_infinity(
const T x)
noexcept {
97template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
98MSTL_CONST_FUNCTION
constexpr bool is_finite(
const T x)
noexcept {
111template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
112MSTL_CONST_FUNCTION
constexpr bool is_normal(
const T x)
noexcept {
114 if (x == 0)
return false;
127template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
130 if (x == 0)
return false;
144template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
145MSTL_CONST_FUNCTION
constexpr bool is_positive(
const T x)
noexcept {
159template <
typename T, enable_if_t<is_
floating_po
int_v<T>,
int> = 0>
160MSTL_CONST_FUNCTION
constexpr bool is_negative(
const T x)
noexcept {
static MSTL_NODISCARD constexpr T infinity() noexcept
获取正无穷大表示
static MSTL_NODISCARD constexpr T min() noexcept
获取类型的最小值
MSTL_CONST_FUNCTION constexpr enable_if_t< is_signed_v< T >, T > absolute(const T x) noexcept
取绝对值(有符号数版本)
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
MSTL_CONST_FUNCTION constexpr bool is_normal(const T x) noexcept
检查浮点数是否为正规数
MSTL_CONST_FUNCTION constexpr bool is_nan(const T x) noexcept
检查浮点数是否为NaN
MSTL_CONST_FUNCTION constexpr bool is_subnormal(const T x) noexcept
检查浮点数是否为次正规数
MSTL_CONST_FUNCTION constexpr bool is_finite(const T x) noexcept
检查浮点数是否为有限值
MSTL_CONST_FUNCTION constexpr bool signbit(const T x) noexcept
获取浮点数的符号位
MSTL_CONST_FUNCTION constexpr bool is_infinity(const T x) noexcept
检查浮点数是否为无穷大
MSTL_CONST_FUNCTION constexpr bool is_neg_infinity(const T x) noexcept
检查浮点数是否为负无穷大
MSTL_CONST_FUNCTION constexpr bool is_pos_infinity(const T x) noexcept
检查浮点数是否为正无穷大
MSTL_CONST_FUNCTION constexpr bool is_positive(const T x) noexcept
检查浮点数是否为正数
MSTL_CONST_FUNCTION constexpr bool is_negative(const T x) noexcept
检查浮点数是否为负数
typename make_integer< Size, IsSigned >::type make_integer_t
make_integer的便捷别名