Isgreaterequal
定义于头文件 <cmath>
中。
描述
确定浮点数 x
是否大于或等于浮点数 y
,而不设置浮点异常。该库为所有 cv-unqualified 浮点类型提供了重载,作为参数 x
和 y
的类型 (自 C++23 起)。
声明
- C++23
- C++11
// 1)
constexpr bool isgreaterequal( /* floating-point-type */ x,
/* floating-point-type */ y );
// 2)
template< class Arithmetic1, class Arithmetic2 >
constexpr bool isgreaterequal( Arithmetic1 x, Arithmetic2 y );
// 1)
bool isgreaterequal( float x, float y );
// 2)
bool isgreaterequal( double x, double y );
// 3)
bool isgreaterequal( long double x, long double y );
// 4)
template< class Arithmetic1, class Arithmetic2 >
bool isgreaterequal( Arithmetic1 x, Arithmetic2 y );
参数
x
, y
- 浮点或整数值
返回值
如果 x >= y
则为 true
,否则为 false
。
备注
浮点数的内置运算符 >=
在其中一个或两个参数为 NaN
时可能会设置 FE_INVALID
。此函数是运算符 >=
的“安静”版本。
不需要严格按照 附加重载 提供附加重载。它们只需要足以确保对于它们的第一个参数 num1
和第二个参数 num2
如果 num1
或 num2
的类型是 long double,则
std::isgreaterequal(num1, num2)
的效果与
std::isgreaterequal(static_cast<long double>(num1), static_cast<long double>(num2))
相同。
否则,如果 num1
和/或 num2
的类型是 double 或整数类型,则
std::isgreaterequal(num1, num2)
的效果与
std::isgreaterequal(static_cast<double>(num1), static_cast<double>(num2))
。
否则,如果 num1
或 num2
的类型为 float,则
std::isgreaterequal(num1, num2)
的效果与
std::isgreaterequal(static_cast<float>(num1), static_cast<float>(num2))
相同。 (直到 C++23)
如果 num1
和 num2
具有算术类型,则
std::isgreaterequal(num1, num2)
的效果与
std::isgreaterequal(static_cast</* common-floating-point-type */>(num1), static_cast</* common-floating-point-type */>(num2))
,
其中 /* common-floating-point-type */ 是 num1
和 num2
类型之间具有最大浮点转换等级和最大浮点转换子等级的浮点类型,整数类型的参数被认为与 double 具有相同的浮点转换等级。
如果不存在具有最高等级和子等级的浮点类型,则重载决议不会从提供的重载中产生可用的候选。