The Is Less Than Or Equal To Comparison Operator checks whether the left value is smaller than or equal to the right value. This operator evaluates to True if the left value is less than or equal to the right value, and False otherwise. It works with Integer and Float types, but cannot mix different numeric types.
The short syntax structure uses the <= symbol:
VALUE <= VALUEThe long syntax structure uses the words IS LESS THAN OR EQUAL TO:
VALUE IS LESS THAN OR EQUAL TO VALUEPRINTLN 5 <= 10 // Displays "TRUE"
PRINTLN 10 <= 5 // Displays "FALSE"
PRINTLN 5 <= 5 // Displays "TRUE"PRINTLN 2.5 <= 3.7 // Displays "TRUE"
PRINTLN 5.0 <= 2.0 // Displays "FALSE"
PRINTLN 3.14 <= 3.14 // Displays "TRUE"PRINTLN -5 <= 0 // Displays "TRUE"
PRINTLN -10 <= -5 // Displays "TRUE"
PRINTLN 0 <= -5 // Displays "FALSE"
PRINTLN -5 <= -5 // Displays "TRUE"NEW INT x = 10
NEW INT y = 20
NEW INT z = 10
PRINTLN x <= y // Displays "TRUE"
PRINTLN y <= x // Displays "FALSE"
PRINTLN x <= z // Displays "TRUE"NEW FLOAT temp1 = 98.6
NEW FLOAT temp2 = 100.0
NEW FLOAT temp3 = 98.6
NEW BOOL isNotHotter = temp1 <= temp2
NEW BOOL isSame = temp1 <= temp3
PRINTLN isNotHotter // Displays "TRUE"
PRINTLN isSame // Displays "TRUE"NEW INT age = 18
NEW BOOL isEligible = age <= 18
PRINTLN isEligible // Displays "TRUE"The Is Less Than Or Equal To operator is commonly used in If statements to check inclusive numeric thresholds.
NEW INT age = 18
IF age <= 17
PRINTLN "Access denied: Must be 18 or older"
ELSE
PRINTLN "Access granted"
END IF
// Displays "Access granted"NEW FLOAT temperature = 32.0
IF temperature <= 32.0
PRINTLN "Freezing or below"
ELIF temperature <= 50.0
PRINTLN "Cold"
ELSE
PRINTLN "Moderate or warm"
END IF
// Displays "Freezing or below"NEW INT score = 80
IF score <= 59
PRINTLN "Grade: F"
ELIF score <= 69
PRINTLN "Grade: D"
ELIF score <= 79
PRINTLN "Grade: C"
ELIF score <= 89
PRINTLN "Grade: B"
ELSE
PRINTLN "Grade: A"
END IF
// Displays "Grade: B"The Is Less Than Or Equal To operator is frequently used to control loop iterations with inclusive boundaries.
NEW INT i = 1
WHILE i <= 5
PRINTLN "Count: " .. i
SET i = i + 1
END WHILE
// Displays: Count: 1, Count: 2, Count: 3, Count: 4, Count: 5NEW INT value = 0
WHILE value <= 10
PRINTLN "Value: " .. value
SET value = value + 2
END WHILE
// Displays: Value: 0, Value: 2, Value: 4, Value: 6, Value: 8, Value: 10NEW INT timer = 5
WHILE timer <= 5
PRINTLN "Timer: " .. timer
SET timer = timer - 1
IF timer <= 0
PRINTLN "Time's up!"
BREAK
END IF
END WHILENEW INT x = 10
NEW INT y = 5
NEW BOOL result = ( x + y ) <= 15
PRINTLN result // Displays "TRUE" ( 15 <= 15 )NEW INT total = 100
NEW INT parts = 3
NEW BOOL isSmall = ( total / parts ) <= 33
PRINTLN isSmall // Displays "TRUE" ( 33 <= 33 )NEW INT a = 5
NEW INT b = 3
NEW INT c = 4
NEW BOOL comparison = ( a + b ) <= ( c * 2 )
PRINTLN comparison // Displays "TRUE" ( 8 <= 8 )NEW INT value = 15
NEW INT min = 10
NEW INT max = 20
NEW BOOL inRange = ( value <= max ) && ( min <= value )
PRINTLN inRange // Displays "TRUE"NEW INT score = 100
NEW BOOL isPerfect = ( score <= 100 ) && ( score <= 100 )
PRINTLN isPerfect // Displays "TRUE"NEW INT age = 18
NEW BOOL hasID = TRUE
NEW BOOL canEnter = ( age <= 21 ) || hasID
PRINTLN canEnter // Displays "TRUE"NEW INT attendees = 100
NEW INT capacity = 100
IF attendees <= capacity
PRINTLN "Venue can accommodate all attendees"
ELSE
PRINTLN "Venue overcapacity"
END IF
// Displays "Venue can accommodate all attendees"NEW FLOAT spent = 250.50
NEW FLOAT budget = 300.00
IF spent <= budget
PRINTLN "Within budget"
ELSE
PRINTLN "Over budget!"
END IF
// Displays "Within budget"NEW INT input = 50
NEW INT maxAllowed = 50
IF input <= maxAllowed
PRINTLN "Valid input: " .. input
ELSE
PRINTLN "Input exceeds maximum allowed value"
END IF
// Displays "Valid input: 50"NEW INT seconds = 10
WHILE seconds <= 10
IF seconds <= 0
PRINTLN "Launch!"
BREAK
END IF
PRINTLN "T-minus " .. seconds .. " seconds"
SET seconds = seconds - 1
END WHILEThe key difference is that Is Less Than Or Equal To ( <= ) includes equal values, while Is Less Than ( < ) does not.
NEW INT x = 10
NEW INT y = 10
PRINTLN x < y // Displays "FALSE" ( 10 is not less than 10 )
PRINTLN x <= y // Displays "TRUE" ( 10 is equal to 10 )NEW INT score = 100
NEW INT maxScore = 100
// Exclusive check ( wrong for this case )
IF score < maxScore
PRINTLN "Below maximum"
END IF
// Inclusive check ( correct )
IF score <= maxScore
PRINTLN "At or below maximum"
END IF
// Displays "At or below maximum"NEW INT x = 25
NEW INT y = 25
PRINTLN x <= y // Displays "TRUE" ( 25 is equal to 25 )NEW INT i = 1
NEW INT target = 3
WHILE i <= target
PRINTLN "Iteration " .. i
SET i = i + 1
END WHILE
// Displays: Iteration 1, Iteration 2, Iteration 3NEW INT userInput = 5
NEW INT minValue = 1
NEW INT maxValue = 10
IF ( minValue <= userInput ) && ( userInput <= maxValue )
PRINTLN "Valid input"
ELSE
PRINTLN "Input out of range"
END IF
// Displays "Valid input"NEW INT points = 90
IF points <= 100
IF points <= 89
PRINTLN "Not quite an A"
ELSE
PRINTLN "Grade A!"
END IF
END IF
// Displays "Grade A!"NEW INT stock = 10
NEW INT reorderPoint = 10
IF stock <= reorderPoint
PRINTLN "Time to reorder!"
ELSE
PRINTLN "Stock level adequate"
END IF
// Displays "Time to reorder!"NEW INT processed = 0
NEW INT total = 5
WHILE processed <= total
SET processed = processed + 1
PRINTLN "Processing item " .. processed
IF processed <= total
PRINTLN "More items to process"
ELSE
PRINTLN "All items processed"
END IF
IF processed <= total
// Continue
ELSE
BREAK
END IF
END WHILENEW INT x = 5
NEW FLOAT y = 10.0
PRINTLN x <= y // Type error! Cannot mix Integer and FloatNEW STR name1 = "Alice"
NEW STR name2 = "Bob"
PRINTLN name1 <= name2 // Type error! Cannot compare Strings with <=NEW BOOL a = TRUE
NEW BOOL b = FALSE
PRINTLN a <= b // Type error! Cannot compare Booleans with <=NEW INT age = 18
// Wrong if you want to exclude 18
IF age <= 18
PRINTLN "18 or younger" // This includes 18
END IF
// Correct for exclusive check
IF age < 18
PRINTLN "Under 18" // This excludes 18
END IF
// Displays "18 or younger"