MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
数值类型检查

浮点数特性检查和特殊值判断 更多...

函数

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool signbit (const T x) noexcept
 获取浮点数的符号位
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_nan (const T x) noexcept
 检查浮点数是否为NaN
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_pos_infinity (const T x) noexcept
 检查浮点数是否为正无穷大
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_neg_infinity (const T x) noexcept
 检查浮点数是否为负无穷大
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_infinity (const T x) noexcept
 检查浮点数是否为无穷大
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_finite (const T x) noexcept
 检查浮点数是否为有限值
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_normal (const T x) noexcept
 检查浮点数是否为正规数
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_subnormal (const T x) noexcept
 检查浮点数是否为次正规数
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_positive (const T x) noexcept
 检查浮点数是否为正数
template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_negative (const T x) noexcept
 检查浮点数是否为负数

详细描述

浮点数特性检查和特殊值判断

函数说明

◆ is_finite()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_finite ( const T x)
constexprnoexcept

检查浮点数是否为有限值

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是有限值则返回true,否则返回false

有限值包括:正常数、负零、正零、次正规数、正规数。

在文件 numeric_types.hpp98 行定义.

引用了 _MSTL, is_infinity() , 以及 is_nan().

被这些函数引用 is_normal() , 以及 is_subnormal().

◆ is_infinity()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_infinity ( const T x)
constexprnoexcept

检查浮点数是否为无穷大

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是无穷大则返回true,否则返回false
注解
此函数不区分正无穷和负无穷

在文件 numeric_types.hpp85 行定义.

引用了 _MSTL, is_neg_infinity() , 以及 is_pos_infinity().

被这些函数引用 is_finite().

◆ is_nan()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_nan ( const T x)
constexprnoexcept

检查浮点数是否为NaN

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是NaN则返回true,否则返回false

NaN的特性:NaN != NaN 总是成立。

在文件 numeric_types.hpp51 行定义.

被这些函数引用 is_finite().

◆ is_neg_infinity()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_neg_infinity ( const T x)
constexprnoexcept

检查浮点数是否为负无穷大

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是负无穷大则返回true,否则返回false

在文件 numeric_types.hpp73 行定义.

引用了 numeric_traits< T, Dummy >::infinity().

被这些函数引用 is_infinity().

◆ is_negative()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_negative ( const T x)
constexprnoexcept

检查浮点数是否为负数

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是负数则返回true,否则返回false

包括:负正规数、负次正规数、负无穷大、负零。

注解
此函数区分正零和负零。

在文件 numeric_types.hpp160 行定义.

引用了 _MSTL , 以及 signbit().

◆ is_normal()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_normal ( const T x)
constexprnoexcept

检查浮点数是否为正规数

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是正规数则返回true,否则返回false

正规数:绝对值大于等于最小正正规数的有限非零浮点数。 不包括:零、次正规数、无穷大、NaN。

在文件 numeric_types.hpp112 行定义.

引用了 _MSTL, absolute(), is_finite() , 以及 numeric_traits< T, Dummy >::min().

◆ is_pos_infinity()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_pos_infinity ( const T x)
constexprnoexcept

检查浮点数是否为正无穷大

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是正无穷大则返回true,否则返回false

在文件 numeric_types.hpp62 行定义.

引用了 numeric_traits< T, Dummy >::infinity().

被这些函数引用 is_infinity().

◆ is_positive()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_positive ( const T x)
constexprnoexcept

检查浮点数是否为正数

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是正数则返回true,否则返回false

包括:正正规数、正次正规数、正无穷大、正零。

注解
此函数区分正零和负零。

在文件 numeric_types.hpp145 行定义.

引用了 _MSTL , 以及 signbit().

◆ is_subnormal()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool is_subnormal ( const T x)
constexprnoexcept

检查浮点数是否为次正规数

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x是次正规数则返回true,否则返回false

次正规数(非正规数):绝对值小于最小正正规数的非零浮点数。 用于表示接近零的非常小的数值。

在文件 numeric_types.hpp128 行定义.

引用了 _MSTL, absolute(), is_finite() , 以及 numeric_traits< T, Dummy >::min().

◆ signbit()

template<typename T, enable_if_t< is_floating_point_v< T >, int > = 0>
MSTL_CONST_FUNCTION constexpr bool signbit ( const T x)
constexprnoexcept

获取浮点数的符号位

模板参数
T浮点数类型
参数
x待检查的浮点数
返回
如果x为负数或负零则返回true,否则返回false

通过检查浮点数的二进制表示中的符号位来判断其符号。

注解
此函数区分正零和负零。

在文件 numeric_types.hpp33 行定义.

被这些函数引用 is_negative() , 以及 is_positive().