Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The >= (greater than or equal to) operator is a binary relational operator that evaluates whether the value of its left operand is mathematically greater than or equal to the value of its right operand. It evaluates the relationship and returns a primitive boolean value: true if the left operand is greater than or equal to the right, and false otherwise.
operand1 >= operand2

Type Compatibility

The >= operator strictly requires numeric operands. It is compatible with:
  • Primitive numeric types: byte, short, char, int, long, float, and double.
  • Wrapper classes: Byte, Short, Character, Integer, Long, Float, and Double. When wrapper classes are used, Java performs auto-unboxing to extract the primitive value before evaluation.
It cannot be applied to boolean types or non-wrapper reference types (such as String or Object).

Evaluation Mechanics

1. Binary Numeric Promotion If the operands are of different numeric types, Java applies binary numeric promotion before performing the comparison. The operand with the “smaller” type is implicitly widened to match the “larger” type according to the Java Language Specification (JLS).
int val1 = 5;
double val2 = 5.0;

// val1 is promoted to double (5.0) before comparison
boolean result = val1 >= val2; // Evaluates to true
2. Character Evaluation When applied to char types, the operator compares their underlying 16-bit unsigned integer Unicode values.
char char1 = 'b'; // Unicode value 98
char char2 = 'a'; // Unicode value 97

boolean result = char1 >= char2; // Evaluates to true
3. Floating-Point Edge Cases (IEEE 754) The operator adheres to IEEE 754 standards for floating-point comparisons:
  • NaN (Not a Number): If either operand is Float.NaN or Double.NaN, the >= operator strictly evaluates to false, even if both operands are NaN.
  • Signed Zeros: Positive zero (+0.0) and negative zero (-0.0) are considered strictly equal. Therefore, +0.0 >= -0.0 evaluates to true.
double num = 10.0;
double nanValue = Double.NaN;

boolean result1 = num >= nanValue;       // Evaluates to false
boolean result2 = nanValue >= nanValue;  // Evaluates to false
boolean result3 = 0.0 >= -0.0;           // Evaluates to true

Operator Precedence

The >= operator has a lower precedence than arithmetic operators (+, -, *, /, %) but a higher precedence than equality operators (==, !=) and logical operators (&&, ||).
int x = 10;
int y = 5;

// Arithmetic (x - 5) is evaluated first, then the relational comparison
boolean result = x >= x - y; // Evaluates to 10 >= 5 (true)
Master Java with Deep Grasping Methodology!Learn More