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