Operations
An operation combines one or more values with an operator to produce a result. Rux groups its operators into the categories below; each has a dedicated page with the full operator list, semantics, and examples.
| Category | Operators | Result |
|---|---|---|
| Arithmetic | + - * / % ** | A numeric value |
| Comparison | == != < <= > >= | A bool |
| Logical | && || ! | A bool |
| Bitwise | & | ^ ~ | An integer (per-bit) value |
| Shift | << >> | An integer value |
| Type Casts | as | The value in the target type |
| Type Tests | is | A bool |
A Shared Rule: No Implicit Conversion
Across every category, Rux never converts between distinct types on your behalf. The operands of a binary operation must already share a type; when they differ, convert one side explicitly with the as cast:
let count: int32 = 10;
let scale: int64 = 2;
let invalid = count * scale; // error: different operand types
let valid = (count as int64) * scale; // int64
This rule keeps the type of every expression visible in the source rather than hidden behind silent promotions.
Precedence
When several operators appear in one expression, precedence decides the grouping — for example ** binds tighter than *, which binds tighter than +. Each page summarises the precedence relevant to its operators; the Operator Precedence table lists every level in one place. Use parentheses whenever the intended order is not obvious.
See Also
- Operators and Punctuation — the complete operator and precedence reference
- Type Casts — the
asoperator used throughout this chapter
Intrinsic Constants
Alongside the constants you declare, the compiler exposes a set of intrinsic values through the build context. Each is a field of an intrinsic — #source, #build, #target, #compiler, or #config — that you import from the standard Rux package and read with .. Because every one is fixed at compile time, it can initialize an ordinary const or serve as a default argument, at no run-time cost.
Arithmetic Operations
Arithmetic operations calculate numeric values. Rux supports arithmetic on integer and floating-point types. Both operands of a binary operation must have the same type; mixed-type expressions require an explicit conversion with as.