Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Integer comparison operators

Collection initializers | Array creation expressions | Delegate creation expressions | Anonymous object creation expressions | The typeof operator | The checked and unchecked operators | Prefix increment and decrement operators | Division operator | Addition operator | Subtraction operator |


Читайте также:
  1. Adverbial clauses of comparison
  2. Adverbial clauses of comparison.
  3. Adverbs Peculiar in Comparison and Formation.
  4. B. DEGREES of COMPARISON
  5. Candidate user-defined operators
  6. Clauses of Manner and Comparison
  7. Comparative advantage is a comparison based on opportunity cost.

The predefined integer comparison operators are:

bool operator ==(int x, int y);
bool operator ==(uint x, uint y);
bool operator ==(long x, long y);
bool operator ==(ulong x, ulong y);

bool operator!=(int x, int y);
bool operator!=(uint x, uint y);
bool operator!=(long x, long y);
bool operator!=(ulong x, ulong y);

bool operator <(int x, int y);
bool operator <(uint x, uint y);
bool operator <(long x, long y);
bool operator <(ulong x, ulong y);

bool operator >(int x, int y);
bool operator >(uint x, uint y);
bool operator >(long x, long y);
bool operator >(ulong x, ulong y);

bool operator <=(int x, int y);
bool operator <=(uint x, uint y);
bool operator <=(long x, long y);
bool operator <=(ulong x, ulong y);

bool operator >=(int x, int y);
bool operator >=(uint x, uint y);
bool operator >=(long x, long y);
bool operator >=(ulong x, ulong y);

Each of these operators compares the numeric values of the two integer operands and returns a bool value that indicates whether the particular relation is true or false.

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 IEEE 754 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. For example, if either of x and y is NaN, then x < y is false, but!(x >= y) is true.

· When neither operand is NaN, the operators compare the values of the two floating-point operands with respect 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 given floating-point format. Notable effects of this ordering are:

o Negative and positive zeros are considered equal.

o A negative infinity is considered less than all other values, but equal to another negative infinity.

o A positive infinity is considered greater than all other values, but equal to another positive infinity.


Дата добавления: 2015-11-16; просмотров: 62 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Shift operators| Reference type equality operators

mybiblioteka.su - 2015-2024 год. (0.006 сек.)