# Arithmetic, comparison, and bit operators

Scalar expressions use explicit arithmetic, comparison, bitwise, shift, and unary operators with ordinary precedence.

Last updated: 2026-09-09

Package: language | Status: stable

Tags: !=, &, *, +, -, /, <, <<, <=, ==, >, >=, >>, ^, arithmetic, cpu, language, logic, yeho, |, ~

Use parentheses when domain meaning is more important than remembering the precedence table.

```yh
left + right
left == right
bits << amount
~bits
```


## Calculate a critical hit

Combine integer damage arithmetic with a boolean threshold.

Verification: executed

```yh
int baseDamage = 40
int multiplier = 150
int damage = (baseDamage * multiplier) / 100
bool critical = damage >= 50
Console.Log(Text.Format("Damage {0}; critical {1}", damage, critical))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__operators"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
Damage 60; critical true
```

Executed backend: cpu-oracle

Observed output:

```text
Damage 60; critical true
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/language--operators/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Operator overloading is unavailable.

Compound assignments such as += and ++ are unavailable. Write value = value + 1.

Source: yeho/parser_expressions.cpp precedence functions; conformance expressions.scalar

AI training permission: https://demonhunterlabs.com/ai-use
