14.9.2 Floating-point comparison operators

The predefined floating-point comparison operators are:
bool operator ==(float x, float y);
bool operator ==(double x, double y);
bool operator !=(float x, float y);
bool operator !=(double x, double y);
bool operator <(float x, float y);
bool operator <(double x, double y);
bool operator >(float x, float y);
bool operator >(double x, double y);
bool operator <=(float x, float y);
bool operator <=(double x, double y);
bool operator >=(float x, float y);
bool operator >=(double x, double y);
The operators compare the operands according to the rules of the IEC 60559
standard:
?If either operand is NaN, the result is false for all operators except
!=, for which the result is true.
For any two operands, x != y always produces the same result as !(x == y).
However, when one or
both operands are NaN, the <, >, <=, and >= operators do not produce the
same results as the logical
negation of the opposite operator. [Example: For example, if either of x
and y is NaN, then x < y is
false, but !(x >= y) is true. end example]
?When neither operand is NaN, the operators compare the values of the two
floating-point operands with
respect to the ordering
?8 < ?max < ? < ?min < ?0.0 == +0.0 < +min < ? < +max < +8
where min and max are the smallest and largest positive finite values that
can be represented in the given
floating-point format. Notable effects of this ordering are:
Negative and positive zeros are considered equal.
A negative infinity is considered less than all other values, but equal to
another negative infinity.
A positive infinity is considered greater than all other values, but equal
to another positive infinity.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值