Numbers, operators and variables in Zlv
How to write numbers, use operators and parentheses, name variables, pick values with when and otherwise, and read exact fractions in Zlv results.
Every Zlv line is an expression: numbers, operators, names and functions. This page covers the building blocks you will use on every sheet.
Numbers
Write numbers the normal way. You can group thousands with commas, and use a leading minus sign for negatives.
Evaluating…
Operators and order of operations
| Operator | Meaning | Example |
|---|---|---|
+ | add | 10 + 5 |
- | subtract | 10 - 5 |
* | multiply | 10 * 5 |
/ | divide | 10 / 4 |
^ | power | 2 ^ 10 |
% or mod | remainder (modulo), between two numbers | 20 % 3, 17 mod 5 (desktop app) |
( ) | group | (10 + 5) * 2 |
Zlv follows the usual order of operations: powers first, then multiplication and division, then addition and subtraction. A number directly before parentheses multiplies, so 2(3 + 4) is 14.
Evaluating…
The desktop app also understands a few words as operators and ! as factorial:
Results appear next to each line in Zlv Desktop. Download it free.
Variables
Assign a value with = or :. The name goes on the left and can contain letters, digits and underscores, starting with a letter. Names cannot contain spaces: use monthly_rent, not monthly rent.
Evaluating…
A variable is available on every line below the one that defines it. If you assign the same name again later, lines below the new assignment use the new value.
Conditions with when and otherwise
Pick a value based on a comparison with when, and give a fallback with otherwise. Comparisons use <, <=, > and >=.
Evaluating…
Exact results in the desktop app
The desktop engine calculates exactly by default. Fractions stay fractions and constants stay symbolic, so 1/3 is shown as 1/3 and 2 * pi * 50 as 100π. Decimal inputs such as 37.5 are exact too and can appear as 75/2.
Results appear next to each line in Zlv Desktop. Download it free.
If you prefer decimals, turn off Exact Mathematics Mode in Settings > Calculation. Right-clicking a result also offers Copy Exact and Copy Decimal. See Settings, themes and languages.
Related pages
- Comments, labels and line references
- Functions and Function Studio for
sqrt,roundand your own functions.