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.
<= (less than or equal to) operator is a binary relational operator that evaluates whether the left operand’s value is mathematically less than or exactly equal to the right operand’s value. It strictly returns a boolean primitive: true if the condition is satisfied, and false otherwise.
Operand Compatibility
The<= operator requires both operands to be convertible to numeric types. It is compatible with:
- Primitive numeric types:
byte,short,char,int,long,float, anddouble. (Note:charis evaluated by its 16-bit unsigned integer Unicode value). - Wrapper classes:
Byte,Short,Character,Integer,Long,Float, andDouble. When a wrapper class is used, Java performs auto-unboxing to extract the primitive value before evaluation. If the wrapper reference isnull, aNullPointerExceptionis thrown during unboxing.
boolean types or non-wrapper reference types (e.g., String, Object).
Binary Numeric Promotion
Prior to the comparison, Java always applies binary numeric promotion to the operands to ensure type uniformity, even if both operands are of the exact same type. The promotion rules are applied in the following order:- If either operand is a
double, the other is promoted todouble. - Otherwise, if either operand is a
float, the other is promoted tofloat. - Otherwise, if either operand is a
long, the other is promoted tolong. - Otherwise, both operands are promoted to
int(this includes comparing twobyte,short, orcharvalues).
Floating-Point Evaluation Rules
When evaluatingfloat or double types, the <= operator adheres to IEEE 754 standards:
- Signed Zeros: Positive zero (
+0.0) and negative zero (-0.0) are considered strictly equal. Therefore,-0.0 <= +0.0and+0.0 <= -0.0both evaluate totrue. - NaN (Not-a-Number): If either or both operands evaluate to
Float.NaNorDouble.NaN, the<=operator will always returnfalse.
Operator Precedence and Associativity
In the Java order of operations, the<= operator is evaluated after arithmetic operators (like +, -, *, /) but before equality operators (==, !=) and logical operators (&&, ||).
While the Java Language Specification defines relational operators with left-to-right associativity, chaining the <= operator (e.g., a <= b <= c) results in a compile-time error. The first evaluation (a <= b) yields a boolean result, which is incompatible with the <= operator for the subsequent numeric comparison against c.
Master Java with Deep Grasping Methodology!Learn More





