ProtoLang.net

Reference: Is Greater Than Or Equal To

☰ Hide Sidebar
TOKEN IS GREATER THAN OR EQUAL TO
ALIAS >=

The Is Greater Than Or Equal To Comparison Operator checks whether the left value is larger than or equal to the right value. This operator evaluates to True if the left value is greater than or equal to the right value, and False otherwise. It works with Integer and Float types, but cannot mix different numeric types.

Syntax

The short syntax structure uses the >= symbol:

VALUE >= VALUE

The long syntax structure uses the words IS GREATER THAN OR EQUAL TO:

VALUE IS GREATER THAN OR EQUAL TO VALUE

Basic Comparisons

Example: Comparing Integer Literals

PRINTLN 10 >= 5 // Displays "TRUE"
PRINTLN 5 >= 10 // Displays "FALSE"
PRINTLN 5 >= 5 // Displays "TRUE"

Example: Comparing Float Literals

PRINTLN 5.7 >= 2.5 // Displays "TRUE"
PRINTLN 2.0 >= 5.0 // Displays "FALSE"
PRINTLN 3.14 >= 3.14 // Displays "TRUE"

Example: Comparing Negative Numbers

PRINTLN 0 >= -5 // Displays "TRUE"
PRINTLN -5 >= -10 // Displays "TRUE"
PRINTLN -5 >= 0 // Displays "FALSE"
PRINTLN -5 >= -5 // Displays "TRUE"

Comparing Variables

Example: Integer Variable Comparison

NEW INT x = 20
NEW INT y = 10
NEW INT z = 20
PRINTLN x >= y // Displays "TRUE"
PRINTLN y >= x // Displays "FALSE"
PRINTLN x >= z // Displays "TRUE"

Example: Float Variable Comparison

NEW FLOAT temp1 = 100.0
NEW FLOAT temp2 = 98.6
NEW FLOAT temp3 = 100.0
NEW BOOL isHotter = temp1 >= temp2
NEW BOOL isSame = temp1 >= temp3
PRINTLN isHotter // Displays "TRUE"
PRINTLN isSame // Displays "TRUE"

Example: Comparing Variable to Literal

NEW INT age = 18
NEW BOOL isAdult = age >= 18
PRINTLN isAdult // Displays "TRUE"

Using Is Greater Than Or Equal To in Conditionals

The Is Greater Than Or Equal To operator is commonly used in If statements to check inclusive numeric thresholds.

Example: Age Validation with Boundary

NEW INT age = 18
IF age >= 18
    PRINTLN "Access granted"
ELSE
    PRINTLN "Access denied: Must be 18 or older"
END IF
// Displays "Access granted"

Example: Temperature Check

NEW FLOAT temperature = 90.0
IF temperature >= 90.0
    PRINTLN "Very hot"
ELIF temperature >= 70.0
    PRINTLN "Warm"
ELSE
    PRINTLN "Cool or cold"
END IF
// Displays "Very hot"

Example: Score Grading with Inclusive Boundaries

NEW INT score = 90
IF score >= 90
    PRINTLN "Grade: A"
ELIF score >= 80
    PRINTLN "Grade: B"
ELIF score >= 70
    PRINTLN "Grade: C"
ELIF score >= 60
    PRINTLN "Grade: D"
ELSE
    PRINTLN "Grade: F"
END IF
// Displays "Grade: A"

Using Is Greater Than Or Equal To in Loops

The Is Greater Than Or Equal To operator is frequently used to control loop iterations with inclusive boundaries.

Example: Inclusive Countdown Loop

NEW INT i = 5
WHILE i >= 1
    PRINTLN "Count: " .. i
    SET i = i - 1
END WHILE
// Displays: Count: 5, Count: 4, Count: 3, Count: 2, Count: 1

Example: Processing Until Threshold Reached

NEW INT value = 20
WHILE value >= 10
    PRINTLN "Value: " .. value
    SET value = value - 2
END WHILE
// Displays: Value: 20, Value: 18, Value: 16, Value: 14, Value: 12, Value: 10

Example: Countdown to Zero

NEW INT timer = 5
WHILE timer >= 0
    PRINTLN "Timer: " .. timer
    SET timer = timer - 1
END WHILE
PRINTLN "Time's up!"
// Displays: Timer: 5, Timer: 4, Timer: 3, Timer: 2, Timer: 1, Timer: 0, Time's up!

Comparing Expression Results

Example: Checking Arithmetic Results

NEW INT x = 10
NEW INT y = 5
NEW BOOL result = ( x + y ) >= 15
PRINTLN result // Displays "TRUE" ( 15 >= 15 )

Example: Checking Multiplication Results

NEW INT width = 5
NEW INT height = 5
NEW BOOL isLarge = ( width * height ) >= 25
PRINTLN isLarge // Displays "TRUE" ( 25 >= 25 )

Example: Comparing Multiple Expressions

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 )

Combining with Logical Operators

Example: Range Checking

NEW INT value = 15
NEW INT min = 10
NEW INT max = 20
NEW BOOL inRange = ( value >= min ) && ( value >= 5 )
PRINTLN inRange // Displays "TRUE"

Example: Multiple Threshold Checks

NEW INT score = 85
NEW BOOL isPassing = ( score >= 60 ) && ( score >= 50 )
PRINTLN isPassing // Displays "TRUE"

Example: Complex Conditions

NEW INT age = 25
NEW BOOL hasExperience = TRUE
NEW BOOL isQualified = ( age >= 21 ) && hasExperience
PRINTLN isQualified // Displays "TRUE"

Practical Applications

Example: Minimum Requirement Check

NEW INT credits = 120
NEW INT requiredCredits = 120
IF credits >= requiredCredits
    PRINTLN "Eligible for graduation"
ELSE
    PRINTLN "Need more credits"
END IF
// Displays "Eligible for graduation"

Example: Capacity Validation

NEW INT attendees = 100
NEW INT capacity = 100
IF capacity >= attendees
    PRINTLN "Venue can accommodate all attendees"
ELSE
    PRINTLN "Venue overcapacity"
END IF
// Displays "Venue can accommodate all attendees"

Example: Finding Maximum Value

NEW INT a = 25
NEW INT b = 18
NEW INT maximum = 0
IF a >= b
    SET maximum = a
ELSE
    SET maximum = b
END IF
PRINTLN "Maximum value: " .. maximum
// Displays "Maximum value: 25"

Example: Quota Achievement

NEW INT sales = 1000
NEW INT quota = 1000
IF sales >= quota
    PRINTLN "Quota met! Bonus awarded."
ELSE
    PRINTLN "Keep working toward quota"
END IF
// Displays "Quota met! Bonus awarded."

Is Greater Than Or Equal To vs Is Greater Than

The key difference is that Is Greater Than Or Equal To ( >= ) includes equal values, while Is Greater Than ( > ) does not.

Example: Boundary Comparison

NEW INT x = 10
NEW INT y = 10
PRINTLN x > y // Displays "FALSE" ( 10 is not greater than 10 )
PRINTLN x >= y // Displays "TRUE" ( 10 is equal to 10 )

Example: Inclusive vs Exclusive Threshold

NEW INT score = 90
NEW INT minScore = 90
// Exclusive check ( wrong for this case )
IF score > minScore
    PRINTLN "Above minimum"
END IF
// Inclusive check ( correct )
IF score >= minScore
    PRINTLN "At or above minimum"
END IF
// Displays "At or above minimum"

Boundary Behavior

Example: Equal Values Return True

NEW INT x = 25
NEW INT y = 25
PRINTLN x >= y // Displays "TRUE" ( 25 is equal to 25 )

Example: Loop with Inclusive Lower Bound

NEW INT i = 5
NEW INT minValue = 1
WHILE i >= minValue
    PRINTLN "Iteration " .. i
    SET i = i - 1
END WHILE
// Displays: Iteration 5, Iteration 4, Iteration 3, Iteration 2, Iteration 1

Common Use Cases

Example: Validating Minimum Value

NEW INT userInput = 5
NEW INT minValue = 5
NEW INT maxValue = 10
IF ( userInput >= minValue ) && ( userInput <= maxValue )
    PRINTLN "Valid input"
ELSE
    PRINTLN "Input out of range"
END IF
// Displays "Valid input"

Example: Passing Grade

NEW INT points = 60
IF points >= 60
    PRINTLN "Pass"
ELSE
    PRINTLN "Fail"
END IF
// Displays "Pass"

Example: Stock Alert

NEW INT stock = 10
NEW INT reorderPoint = 10
IF stock >= reorderPoint
    PRINTLN "Stock level adequate"
ELSE
    PRINTLN "Time to reorder!"
END IF
// Displays "Stock level adequate"

Example: Processing Until Complete

NEW INT remaining = 5
WHILE remaining >= 0
    PRINTLN "Items remaining: " .. remaining
    SET remaining = remaining - 1
END WHILE
PRINTLN "All items processed"

Important Notes

  • Is Greater Than Or Equal To ( >= ) returns True if the left value is larger than or equal to the right value.
  • Equal values return True; use Is Greater Than ( > ) for strictly larger comparisons.
  • Both values must be the same numeric Data Type ( both Integer or both Float ).
  • The result is always a Boolean ( True or False ).
  • Cannot compare Strings or Booleans with Is Greater Than Or Equal To.
  • Use >= for inclusive lower bounds in loops and minimum value checks.

Common Errors

Error: Mixing Integer and Float

NEW INT x = 10
NEW FLOAT y = 5.0
PRINTLN x >= y // Type error! Cannot mix Integer and Float

Error: Using with Strings

NEW STR name1 = "Bob"
NEW STR name2 = "Alice"
PRINTLN name1 >= name2 // Type error! Cannot compare Strings with >=

Error: Using with Booleans

NEW BOOL a = TRUE
NEW BOOL b = FALSE
PRINTLN a >= b // Type error! Cannot compare Booleans with >=

Error: Using Wrong Operator for Exclusive Comparison

NEW INT points = 100
// Wrong if you want to exclude 100
IF points >= 100
    PRINTLN "100 points or more" // This includes 100
END IF
// Correct for exclusive check
IF points > 100
    PRINTLN "More than 100 points" // This excludes 100
END IF
// Displays "100 points or more"