Documentation

Numbers in a note

Every form the calculator accepts: units, money, percentages, variables.

Written against app/src/calc/, and every line below is asserted in spec.test.ts, settings.test.ts, completion.test.ts or tuning.test.ts.

Activation

There is none, deliberately. Every note calculates, and a line is a calculation when it ends in =. That gesture is the whole opt-in: prose is never disturbed, and there is no keyword to remember.

  • // anything — a comment. Not read, even when its contents are valid math.
  • math: Your Title — a title. Recognised so that it does not become a variable named math, which is what it used to be.
  • Fenced code, indented code and YAML frontmatter are quoted, not computed.

Calculations

+ - * x X / ÷ ^ ** ( ), and → / -> for conversions.

Words, punctuation and currency symbols are stripped when a line does not otherwise compute — dinner 20 + tip 5 = 25. This is a fallback, on additive lines only: model 3 x 2024 = stays prose, and so does a sentence with a single figure in it.

Percentages: 100 + 15%, 50% of 200, 10% off 250, 250 less 10%, 15 increased by 20%, what % of 200 is 50, 80 as a % of 200.

Advanced: !, !! (a true double factorial), √16, ∛8, sqrt(), cbrt(), log() (natural), log2(), log10(), ceil(), floor(), round(), abs(), nthRoot(), mean()/avg(), pi, e.

Numbers: 1,200 and 1,000,000; 1.000,25 where both separators are present; 5k, 2bn; 1 1/2 and ½. A bare comma decimal (0,50) is ambiguous and left alone. Space-grouped thousands are not supported.

Conversions inside a calculation are still not supported (5cm to inches * 5).

Settings ⟶ Math

In the settings palette, alongside Appearance and Behavior.

Setting Values Default
Decimal places Automatic, 0–7 Automatic
Thousands separator on / off on
Primary currency any supported code USD
Secondary currency none, or any code none
Currency symbol any supported glyph $
Update currency rates daily on / off on
Custom currency rates NTD:30.23, XPF:110 empty

"Decimal places" rather than significant figures: three significant figures turn 1,618.7 m² into 1,620 and a mile into 1.61e+6 mm. Automatic keeps the scale-aware rule, which suits a document that mixes 473 ml with 0.0625 cups.

Rate updates off means no request leaves the machine. A table already in memory still counts, and so do custom rates.

Custom rates are units per one unit of the primary currency, and they beat the fetched figure — somebody who typed a rate in has a bank's number rather than the mid-market one.

Currency

10 USD to JPY =     $10 to JPY =     $10 =   (with a secondary currency set)
    

The full circulating ISO-4217 set and 55 crypto tickers. Fiat comes from the ECB's reference rates, with a wider feed filling the currencies the ECB does not publish — asked only when a note names one. Crypto comes from CoinGecko. Withdrawn codes (DEM, ATS, BYR…) are not recognised, and neither are KPW or SVC, which no feed prices.

Symbols: $ € £ ¥ ₹ ₩ ₽ ₺ ₴ ₦ ₪ ₱ ﷼ ₫ ₡ ₲ ฿ ₵ ₭ ₾ ₸ ₮

Word-shaped codes — CUP, KGS, ALL, TOP, PEN, BOB, GEL, MAD and the rest — are money only in capitals. 1 cup to tbsp is a recipe.

Measurements

Distance m, cm, mm, km, in/inch/"/″, ft/foot/feet/'/′, yard, mile, and compound heights (5' 10").

Area sqm, sqcm, sqmm, sqkm, sqin, sqft, sqyd, sqmi, hectare, acre — each also as sq m, square meters, m². Plus are, dunam/donum, tsubo / ping / pyeong, bigha, cuerda, rood, perch, section, township. The ones that are also English words are units only inside a conversion.

Volume liter, ml, m³/cm³/mm³ (also cubic meter, cu ft…), cuin, cuft, cuyd, cc, gallon, quart, pint, cup, fl oz, tbsp, tsp — and the whole imperial family as uk <measure> or imperial <measure>.

Mass kg, g, mg, mcg/µg, tonne, lb, oz, stone, and short / long / metric / us / uk / imperial ton.

Temperature 20 C, 20 °C, 20 celsius, 20 degrees Celsius, 20 centigrade, the same for F, and 300 K / kelvin / degrees K.

Inches come back the way a tape measure reads: 58 cm to in = 22 13/16″. Setting a fixed decimal precision turns that off.

Variables

number of guests : 9
    number of guests + 1 = 10
    

Names may contain spaces. A definition applies only to the lines below it, and redefining one changes only what follows. Autocomplete opens at three characters over the names defined above the cursor: Tab takes the first, and a number key takes the one beside it when there is more than one.

A conversion assigned to a variable stores the number and not the unit, so the unit has to be written again to convert it onward:

cost in CAD : 50 USD to CAD
    cost in CAD CAD to USD = 50.00 USD