13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 14 Expressions14.9.2 Floating-point comparison operatorsThe 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 (double x, double 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 orboth operands are NaN, the , = operators do not produce the same results as the logicalnegation of the opposite operator. [Example: For example, if either of x and y is NaN, then x < y isfalse, but !(x >= y) is true. end example]• When neither operand is NaN, the operators compare the values of the two floating-point operands withrespect to the ordering–∞ < –max < … < –min < –0.0 == +0.0 < +min < … < +max < +∞where min and max are the smallest and largest positive finite values that can be represented in the givenfloating-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.14.9.3 Decimal comparison operatorsThe predefined decimal comparison operators are:bool operator ==(decimal x, decimal y);bool operator !=(decimal x, decimal y);bool operator (decimal x, decimal y);bool operator =(decimal x, decimal y);Each of these operators compares the numeric values of the two decimal operands and returns a boolvalue that indicates whether the particular relation is true or false. Each decimal comparison isequivalent to using the corresponding relational or equality operator of type System.Decimal.14.9.4 Boolean equality operatorsThe predefined boolean equality operators are:bool operator ==(bool x, bool y);bool operator !=(bool x, bool y);The result of == is true if both x and y are true or if both x and y are false. Otherwise, the result isfalse.165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!