1#ifndef NEFORCE_CORE_NUMERIC_NUMERIC_TYPES_HPP__
2#define NEFORCE_CORE_NUMERIC_NUMERIC_TYPES_HPP__
14NEFORCE_BEGIN_NAMESPACE__
33NEFORCE_CONST_FUNCTION
constexpr enable_if_t<!(
sizeof(T) == 16 && numeric_traits<T>::digits == 64),
bool>
38 const UInt bits = *
reinterpret_cast<const UInt*
>(&x);
39 constexpr UInt sign_mask =
static_cast<UInt
>(1) << (8 *
sizeof(UInt) - 1);
40 return (bits & sign_mask) != 0;
44NEFORCE_CONST_FUNCTION
constexpr enable_if_t<
sizeof(T) == 16 && numeric_traits<T>::digits == 64,
bool>
45signbit(
const T x)
noexcept {
46 static_assert(is_floating_point_v<T>,
"floating point required");
52 return (buf.data[9] & 0x80) != 0;
65NEFORCE_CONST_FUNCTION
constexpr bool is_nan(
const T x)
noexcept {
102NEFORCE_CONST_FUNCTION
constexpr bool is_infinity(
const T x)
noexcept {
115NEFORCE_CONST_FUNCTION
constexpr bool is_finite(
const T x)
noexcept {
129NEFORCE_CONST_FUNCTION
constexpr bool is_normal(
const T x)
noexcept {
136 const T abs = x < 0 ? -x : x;
150NEFORCE_CONST_FUNCTION
constexpr bool is_subnormal(
const T x)
noexcept {
157 const T abs = x < 0 ? -x : x;
158 return abs < numeric_traits<T>::min();
172NEFORCE_CONST_FUNCTION
constexpr bool is_positive(
const T x)
noexcept {
173 return x > 0 || (x == 0 && !_NEFORCE
signbit(x));
187NEFORCE_CONST_FUNCTION
constexpr bool is_negative(
const T x)
noexcept {
188 return x < 0 || (x == 0 && _NEFORCE
signbit(x));
193NEFORCE_END_NAMESPACE__
static constexpr T infinity() noexcept
获取正无穷大表示
static constexpr T min() noexcept
获取类型的最小值
constexpr bool is_floating_point_v
is_floating_point的便捷变量模板
constexpr void * memory_copy(void *__restrict dest, const void *__restrict src, size_t count) noexcept
从源内存复制到目标内存
constexpr bool is_finite(const T x) noexcept
检查浮点数是否为有限值
constexpr bool is_positive(const T x) noexcept
检查浮点数是否为正数
constexpr bool is_nan(const T x) noexcept
检查浮点数是否为NaN
constexpr bool is_normal(const T x) noexcept
检查浮点数是否为正规数
constexpr bool is_infinity(const T x) noexcept
检查浮点数是否为无穷大
constexpr bool is_negative(const T x) noexcept
检查浮点数是否为负数
constexpr bool is_neg_infinity(const T x) noexcept
检查浮点数是否为负无穷大
constexpr enable_if_t<!(sizeof(T)==16 &&numeric_traits< T >::digits==64), bool > signbit(const T x) noexcept
获取浮点数的符号位
constexpr bool is_subnormal(const T x) noexcept
检查浮点数是否为次正规数
constexpr bool is_pos_infinity(const T x) noexcept
检查浮点数是否为正无穷大
typename make_integer< Size, IsSigned >::type make_integer_t
make_integer的便捷别名
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名