TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
> (greater than) operator is a binary relational operator that evaluates whether the value of its left operand is strictly greater than the value of its right operand. It yields an int result of 1 if the condition is true, and 0 if the condition is false.
Technical Mechanics
- Return Type: The result of the
>operator is always of typeint, regardless of the types of the operands. C does not natively return a boolean type from relational operators. - Associativity: Left-to-right. An expression like
a > b > cis parsed as(a > b) > c. Because the result of(a > b)is either0or1, the subsequent comparison is evaluated as0 > cor1 > c. - Precedence: The
>operator has lower precedence than arithmetic operators (like+,-,*,/) but higher precedence than equality operators (==,!=) and logical operators (&&,||).
Operand Rules and Type Promotion
The operator accepts operands of real type (integer or floating-point) or pointer type, governed by strict rules defined by the C Standard: 1. Arithmetic Operands When both operands have arithmetic types, the compiler applies the usual arithmetic conversions before performing the comparison to establish a common real type.- Integer Promotions: Operands of lower integer conversion ranks (e.g.,
char,short) are first promoted tointifintcan represent all values of the original type. Otherwise, they are promoted tounsigned int(e.g., anunsigned shorton a system whereshortandintare both 16-bit). - Floating-Point Hierarchy: Floating-point conversions are handled by a separate hierarchy, distinct from integer conversion ranks. If either operand is a floating-point type, the operand with the lower type is converted to the higher type (e.g., comparing an
intand adoublecauses theintto be converted todouble). - Integer Conversion Rank and Mixed Signs: If both operands are integers of different types, integer conversion ranks dictate the promotion.
- If the operands have the same rank but different signedness, the signed operand is converted to unsigned.
- If the unsigned operand has a lower rank, and the signed operand’s type can represent all values of the unsigned type, the unsigned operand is converted to the signed type.
- If the higher-rank signed type cannot represent all values of the lower-rank unsigned type (e.g., a 32-bit
longand a 32-bitunsigned int), both operands are converted to the unsigned version of the higher-rank type.
- Negative to Unsigned Conversion: When a signed integer is converted to an unsigned integer during these promotions, a negative value is mathematically converted to a large positive unsigned value (e.g.,
-1becomesUINT_MAX). This can lead to unexpected comparison results if not carefully managed.
> if both point to compatible object types.
- The C standard abstracts memory and does not mandate or assume virtual memory. Pointer comparison is strictly defined in terms of array subscripts and object layouts.
- Comparing pointers using
>is strictly valid only if both pointers point to elements within the same array object (or one past the last element), or to members of the same aggregate object. In C, only arrays and structures are aggregate types. - For arrays, a pointer to an element with a higher subscript compares greater than a pointer to an element with a lower subscript.
- For structures, pointers to members declared later in the
structcompare greater than pointers to members declared earlier. - Comparing pointers to distinct, unrelated objects results in undefined behavior.
Syntax Visualization
Master C with Deep Grasping Methodology!Learn More





