Dotdown™ · formulas
Steps and formulas
A calculator is a list of steps. Each step has a label and a formula, and a later step can use any earlier result.
A step
.r1 Subtotal (RM): qty × price.r2 Total (RM): r1 + r1 × 0.06
- Number steps
.r1,.r2, … with no gaps. The last one is the answer. - Label, optional
(unit), then a colon and the formula. If a label has a colon in it, only the last colon starts the formula. - A step can use
r1,r2… from steps above it, never from below.r1style names are reserved for results. - Any other word is a variable. Declare it with
.inputto give it a label and a rule, or just use it and it is found anyway. See Inputs.
Operators and brackets
.r1 Plain: 2 + 3 × 4// 14, because × and ÷ go first.r2 Brackets: (2 + 3) × 4// 20.r3 Typed fast: 10 / 4 - 1// 1.5, the same as 10 ÷ 4 − 1
- Use
+ − × ÷. The plain- * /work too and are turned into the real symbols. ×and÷go before+and−. Use brackets to change the order.- A minus in front of a number, like
-5, is a negative number. - Dividing by a typed
0is flagged as you type.
If / then / else
.input qty: Quantity.input price: Price (RM).r1 Subtotal: qty × price.r2 Discount: if qty > 100 then r1 × 0.1 else 0.r3 Fee: if qty >= 10 then 0 else 5.r4 Not five: if qty <> 5 then 1 else 0
Six comparisons:
> | greater than |
< | less than |
= | equals |
>= (or ≥) | at least |
<= (or ≤) | at most |
<> (or ≠) | not equal |
- The working shows only the branch that is taken. Both branches are still calculated, so one that cannot be calculated (say, a division by zero) stops the whole step.
- A comparison can only sit inside an
if, or be a whole formula by itself. - Both sides of a comparison can be formulas:
if r1 × 2 > price then ….
And, or, not
.r1 Free shipping: if total >= 100 or member = 1 then 0 else 8.r2 Allowed: if age >= 18 and age <= 65 and not income > 8000 then 1 else 0.r3 Eligible: age >= 18 and income < 5000
notgoes first, thenand, thenor. Use brackets to group:(a > 1 or b > 1) and c > 1.- They join comparisons. They are not functions, so
and(a, b)does not work. - Both sides are always calculated. If the right side cannot be calculated, the whole thing cannot, even when the left side already decides it.
A yes / no answer
A formula that is only a comparison, or comparisons joined with and / or / not, gives true or false. That is how an eligibility check works.
.r1 Can apply: age >= 18 and income < 5000// shows true or false
Exact decimals
Every number is an exact decimal, not a floating-point one: 0.1 + 0.2 is exactly 0.3. Division is calculated to 100 digits and then shown with your decimal places. Choose the places and rounding in Settings.
When it cannot calculate
- Dividing by zero, the square root of a negative number, or a list function on an empty list gives no answer for that step, and for every later step that uses it.
- A formula with a mistake, such as a missing bracket or a comparison with nothing to compare, is reported with its line number when you press “To calculator”, and nothing changes. Click the line number to jump to it.
Looking for sqrt, pmt, mean and the rest? See Functions.