Skip to main content

Relational Operators

These operations are used to compare numeric (integer and float) values.

info

These operators can compare values with asymmetric types, meaning that an integer can be compared directly to a float.

Less Than or Equal (<=)

This operation evaluates to true if the left-hand value is less than or equal to the right-hand value and false otherwise.

knot
const foo = 5;
const bar = 2;
foo <= 10.5 == true;
foo <= bar == false;
foo <= 5 == true;
knot
const foo = 5;
const bar = 2;
foo <= 10.5 == true;
foo <= bar == false;
foo <= 5 == true;

Less Than (<)

This operation evaluates to true if the left-hand value is less than or equal to the right-hand value and false otherwise.

knot
const foo = 5;
const bar = 2;
foo < 10.5 == true;
foo < bar == false;
foo < 5 == false;
knot
const foo = 5;
const bar = 2;
foo < 10.5 == true;
foo < bar == false;
foo < 5 == false;

Greater Than or Equal (>=)

This operation evaluates to true if the left-hand value is greater than or equal to the right-hand value and false otherwise.

knot
const foo = 5;
const bar = 2;
foo >= 10.5 == false;
foo >= bar == true;
foo >= 5 == true;
knot
const foo = 5;
const bar = 2;
foo >= 10.5 == false;
foo >= bar == true;
foo >= 5 == true;

Greater Than (>)

This operation evaluates to true if the left-hand value is greater than the right-hand value and false otherwise.

knot
const foo = 5;
const bar = 2;
foo > 10.5 == false;
foo > bar == true;
foo > 5 == false;
knot
const foo = 5;
const bar = 2;
foo > 10.5 == false;
foo > bar == true;
foo > 5 == false;