14.9.2 Floating-point comparison operators

王朝other·作者佚名  2006-04-12
窄屏简体版  字體: |||超大  

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.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航