စံကား

05Operators

Comparison

Ask whether values are equal, greater or less.

A comparison asks a true-or-false question about two values: are the two equal? Is one bigger? The answer is a boolean, မှန် or မမှန်.

စံကား

Expected output

မှန်
မမှန်
မှန်
မှန်
မမှန်
မှန်

All six comparisons

SignWordsReads as
a == ba သည် b နှင့် ညီသည်a is equal to b
a != ba သည် b နှင့် မညီပါa is not equal to b
a > ba သည် b ထက် ကြီးသည်a is greater than b
a <= ba သည် b ထက် မကြီးပါa is not greater than b
a < ba သည် b အောက် ငယ်သည်a is less than b
a >= ba သည် b အောက် မငယ်ပါa is not less than b

The မ in front of a verb means "not": မညီ is "not equal", မကြီး is "not greater". Equals uses = twice: ==. A single = is not an operator in Zaka.

စံကား

Expected output

မှန်
မှန်
မှန်

Characters can be compared too. Their order follows the Unicode number, so 'က' comes before 'ခ', and 'A' (65) comes before 'a' (97):

စံကား

Expected output

မှန်
မှန်

Keeping the answer

A comparison is a value, so it can be stored in a boolean variable:

စံကား

Expected output

မှန်

One comparison at a time

Maths allows 1 < 2 < 3. Zaka does not allow a comparison inside another comparison:

စံကားZK0210

Expected error

error[ZK0210]: a comparison cannot be the operand of another comparison

Ask two questions and join them with "and" instead: ၁ < ၂ ဖြစ်၍ ၂ < ၃. The next page, Logic, shows how.

Hands on

  • Print whether 7 is not equal to 7, in words and in signs.
  • Store whether an age is at least 18 in a variable, then print it.

Next: Logic.