Skip to content
nikolaeu edited this page Dec 22, 2023 · 16 revisions

Documentation

Unit Conversion

With in (into, as, to) you can convert one unit into another. Numi will automatically convert units to perform operations if it's needed during conversion. $30 in Euro $30 CAD + 5 USD - 7EUR

Time Zone Conversion

Use time or now function to get time in your time zone. You can prefix this functions with time zone location (or use in with time zone suffix) to get current time for specified location. Results are always in sync with global time, so, at any point of time you will get the right time.

It's also possible to convert specific time or date from one time zone into another. Or calculate difference between time in different time zones:

PST time
New York time
Time in Madrid
2:30 pm HKT in Berlin

Operations

You can use sign and word operators. Several expressions might be stacked together. Notice, expressions will be multiplied if used in parentheses one after another.

8 times 9
1 meter 20 cm = 120 cm
6 (3) = 18
Operation Sample
Addition +, plus, and, with
Subtraction -, minus, subtract, without
Multiplication *, times, multiplied by, mul
Division /, divide, divide by
Exponent ^
Bitwise And &
Bitwise Or |
Bitwise Xor xor
Left Shift <<
Right Shift >>
Modulo mod

Numbers

Besides decimal numeral system, it is possible to use numbers in binary, octal or hexadecimal form using appropriate prefix: 0b, 0o and 0x. You can use sci or scientific to format results in scientific notation.

0b110111011
0o1435343 in hex
5 300 in sci

Currency

You can use ISO 4217 codes for currency (like USD, RUB, CAD etc). You can also use common currency names and signs, like $ for the US dollars, roubles for Russian roubles, or for Euro. Numi updates currency rates several times a day using open exchange rates service. Numi also supports a huge list of cryptocurrencies with hourly rates updates.

Percentage

In addition to general percentage operations like adding or subtracting percent of value ($10 - 40%), you also can use additional operations :

Operation Example
Percentage value 20% of $10
Adding percentage 5% on $30
Subtracting percentage 6% off 40 EUR
Percentage value of one value relative to another $50 as a % of $100
Percentage addition of one value relative to another $70 as a % on $20
Percentage subtraction of one value relative to another $20 as a % off $70
Value by percent part 5% of what is 6 EUR
Value by percent addition 5% on what is 6 EUR
Value by percent subtraction 5% off what is 6 EUR

Scales

Scales used for shorter form of writing big numbers. Please note that one-letter scales are case-sensitive, since m used for meters, and K used for Kelvins. Supported scales: thousands (k, thousand), millions (M, million), billions (billion).

$2k
2M eur

Variables

You can declare variables and reuse them using the = operator. Please note some characters and keywords cannot be used as a variable. For example, K might be used as a temperature unit in Kelvin. Variable names should not contain whitespaces or special characters, and should not start with number:

v = $20
v2 = 5%
v times 7 - v2
v + $10

Constants

Description Value
Pi 3.1415926536
E 2.7182818285

Functions

By default trigonometrical functions uses parameters in radians.

Description Function Example
N-th root root root 2 (8)
Square root sqrt sqrt 16
Cubed root cbrt cbrt 8
Absolute value abs abs(-4)
Logarithm log log 2 (10)
Natural logarithm ln ln 3
Factorial fact fact 5
Rounding round round 3.45
Ceiling ceil ceil 3.76
Flooring floor floor 2.56
Sine sin sin 45°
Cosine cos cos 3.45
Tangent tan tan 8
Arcsine arcsin arcsin 30
Arccosine arccos arccos 85
Arctangent arctan arctan 9
Hyperbolic sine sinh sinh 3
Hyperbolic cosine cosh cosh 9
Hyperbolic tangent tanh tanh 11

CSS

Numi supports several CSS units: pixels (px), points (pt), em. Em is set to 16 px by default, but you can assign different value to it. Conversion from screen units to other length units performed using pixel per inch value (ppi). By default ppi is set to 96 pixels, which mean in every inch there're 96 pixels. You can set custom value for ppi.

12 pt in px
em = 20px
1.2 em in px
1 inch in px = 96 px
ppi = 326
1 cm in px = 128,35 px

Previous Result

Use prev token to use result from previous line:

Cost: $20 + 56 EUR
Discounted: prev - 5% discount

Sum

You can calculate sum of all lines above (until empty line) using sum ( total ) operator.

Line 1: $10
Line 2: $15
Result: sum

Average

You can calculate an average of all lines above (until empty line) using average ( avg ) operator.

Line 1: $10
Line 2: $20
Result: average

SI prefixes

SI-based units support all SI prefixes, both short and long form. Note that SI prefixes are case-sensitive. For example, use MB for megabytes, not mB:

1 mm
2 picometers
3 GB

Date & Time

To make time calculations more straightforward, 1 year is equal to 365 days, and 1 month equal to 1/12 of the year. In cases where results give non-integer value, round functions might be used to make an integer. Supported units: Second, minute, hour, day, week, month, year. Use fromunix function to convert timestamp into dates.

round(1 month in days)
fromunix(1446587186)

Temperature

Supported units: kelvin, celsius, fahrenheit

Length

Supported units: meter, mil, points, lines, inch, hand, foot, yard, rod, chain, furlong, mile, cable, nautical mile, league. Note, since in used as a conversion operator, you cannot use it for inches.

Area

Supported units: hectare, are, acre and all "squared" length units. Use square or sq prefix for this case.

20 sq cm
30 square inches
11 sqm

Volume

Supported units: Pint, quart, gallon, tea spoon, table spoon, cup. It is possible to use all length units with cubic, cu or cb prefix.

20 cu cm
30 cubic inches
11 cbm

Weight

Supported units: gram, tonne, carat, centner, pound, stone, ounce.

Angular

Supported units: radians, degree. You can use both as text form of unit (radians, degrees) as sign. For example, 45 °

Data

Bytes multiplies contain 1000 bytes. If you need 1024 multiplier, use kibibytes. Please note lowercase b is used for bits, and uppercase B for bytes.

Format

Use hash symbol at the beginning of the line to make a header. If you want to comment part of the line, use double quotes. To comment all line, use double slash. Use colon to make a label (label will not be evaluated).

# This is header
$275 for the "Model 227"
// This is comment
Price: $11 + $34.45

Shortcuts

Surround with parentheses ⇧⌘0
Copy result on current line ⇧⌘C
Select all ⌘A
Delete all ⎇⌘⌫
Copy all ⎇⌘C
Import ⌘O
Export ⌘S
Print ⌘P

Import & Export

Numi does not modify imported files until you explicitly export them. All exported files have .numi extension. You can open .numi files with any text editor since Numi uses plain text and UTF-8 encoding to store files.

Alfred

You can use Numi with Alfred for quick calculations. Just type numi, n or = in front of your expressions in Alfred. Please note, time zones functionality is not available via integration.

First you will need to install the Numi workflow, and enable Alfred integration in Numi preferences.

For the LaunchBar extension please refer to https://github.com/Rahlir/NumiLaunchbar.

gif

Plugins

You can use JavaScript extensions to add global variables, custom units or functions. Right now only limited set of API is available via JavaScript, but the plan is to open as much API as possible.

Extension folder located in ~/Library/Application Support/com.dmitrynikolaev.numi/extensions of your home folder. Open finder app, choose Go -> Go to Folder in menu (Or use shortcut Cmd+Shift+G) and type ~/Library/Application Support/com.dmitrynikolaev.numi/extensions in destination. Press Go button and you'll navigate to the extension folder.

Use ~/Library/Application Support/com.nikolaeu.numi-setapp/extensions for SetApp version.

Numi extension logs should be viewable via the Console application. Open Console app, type NumiExtension in the search bar, and choose category filter to focus on the extension logs.

Logging

Use log function to send output from your extension to log window.

js log("Function called!");

Values and Variables

Each value in Numi might be represented in JavaScript as an object with a set of properties, describing decimal value, unit type etc. Here is the usual way of creating new values for Numi:

js var value = { "double": 5, "unitId" : "USD" }

Use numi.setVariable function to declare global variables.

js numi.setVariable("xxx", { "double": 5, "unitId" : "USD" });

You can also use plain JavaScript numbers for cases when you'll need to return value for Numi. This will be treated as a value with decimal number.

js numi.setVariable("yyy", 122);

Custom Units

Use numi.addUnit to add new unit. id field required for internal use, and might be any unique literal. phrases contains string with comma-separated phrases that might be used for the unit, format field used for results formatting.

Unit conversion limited to ratio-based conversion ATM. For each unit you can specify base unit identifier baseUnitId and ratio to that unit. Conversion from one unit to another in this case happening through base unit. On first step value will be converted to the base unit. On second step base value will be converted to result unit. baseUnitId might be picked up from list of base units.

js numi.addUnit({ "id": "horse", "phrases": "horse, horses, hrs", "baseUnitId": "m", "format" : "hrs", "ratio" : 2.4, });

Custom Functions

Use numi.addFunction to add new function. Values passed into evaluated function in form of array. To use function with multiple arguments you can use ; in Numi, like myFunction(1;5;4).

js numi.addFunction({ "id": "zum", "phrases": "zum" }, function(values) { return { "double": values[0].double + values[1].double }; });

List of Base Units

Unit name Unit ID
Meter m
Second second
Percentage percent
Square meter m2
Cubic meter m3
Bit bit
Byte byte
Radian radian
Gram gram
US Dollars USD

Sample Extensions