Ze supports the standard set of arithmetic, comparison, and logical operators. Every operator has both a symbol form and one or more word forms in all three languages.
Arithmetic
| Operation | Symbol | English word | Tagalog word | Bisaya word |
|---|---|---|---|---|
| Add | + | plus | dagdag | dagdag |
| Subtract | - | minus | bawas | bawas |
| Multiply | * | times / multiply | beses | pilo |
| Divide | / | divide | hatiin | bahinon |
| Modulo | % | remainder / modulo | natira | nahibilin |
| Power | ^ | power / squared | puwersa | gahum |
show 10 + 3 # 13
show 10 minus 3 # 7
show 4 times 5 # 20
show 10 divide 4 # 2.5
show 10 remainder 3 # 1
show 2 ^ 8 # 256
Comparison
All comparison operators return true or false.
| Meaning | Symbol | English phrase | Tagalog phrase | Bisaya phrase |
|---|---|---|---|---|
| Equal | == | is / is equal to | ay / ay katumbas ng | mao / katumbas sa |
| Not equal | != | is not / is not equal to | ay hindi | dili sama sa / dili katumbas sa |
| Greater than | > | is greater than | ay mas malaki sa | mas dako sa |
| Less than | < | is less than | ay mas maliit sa | mas gamay sa |
| Greater than or equal | >= | is at least / is greater than or equal | ay hindi bababa sa | dili moubos sa |
| Less than or equal | <= | is at most / is less than or equal | ay hindi lalampas sa | dili molapas sa |
show 5 is 5 # true
show 5 is not 3 # true
show 10 is greater than 7 # true
show 3 is less than 8 # true
show 5 is at least 5 # true (>=)
show 4 is at most 10 # true (<=)
# Tagalog
show 10 ay mas malaki sa 7 # true
show 5 ay hindi bababa sa 5 # true
# Bisaya
show 10 mas dako sa 7 # true
show 5 dili moubos sa 5 # true
Logical
| Operator | English | Tagalog | Bisaya |
|---|---|---|---|
| AND | and / and also | at / at saka | ug / ug usab |
| OR | or / or else | o / o kaya | o / o kaha |
| NOT | not | hindi | dili |
show true and false # false
show true or false # true
show not true # false
# Tagalog
show totoo at mali # false
show totoo o mali # true
show hindi totoo # false
# Bisaya
show tinuod ug bakak # false
show tinuod o bakak # true
show dili tinuod # false
Precedence (highest to lowest)
| Level | Operators |
|---|---|
| 8 — Power | ^ / power / puwersa / gahum |
| 7 — Multiply/Divide | * / % and word forms |
| 6 — Add/Subtract | + - and word forms |
| 5 — Comparison | == != < > <= >= and phrase forms |
| 3 — NOT | not / hindi / dili |
| 2 — AND | and / at / ug |
| 1 — OR | or / o |
Use parentheses ( ) to override precedence:
show 2 + 3 * 4 # 14 (multiply first)
show (2 + 3) * 4 # 20 (parens first)
String Concatenation
The + operator concatenates strings. If either operand is not a string, it is automatically converted.
show "Hello, " + "World!" # Hello, World!
show "Score: " + word(score) # Score: 95
show "Items: " + count fruits # Items: 3