Skip to content

Units & Dimensional Analysis

Kalc features a built-in dimensional analysis engine. Rather than treating units as superficial text labels, Kalc models physical quantities as dimensional vectors across 10 fundamental base dimensions, ensuring that unit additions, multiplications, and conversions maintain strict dimensional correctness.


The 10 Base Dimensions

All physical quantities resolve internally to base dimensional units:

DimensionBase UnitSupported Units & Common Aliases
Lengthm (meter)m, cm, mm, km, inch (in, "), foot (ft, '), yard (yd), mile (mi), nautical mile, pt, mil
Aream2 (sq meter)sqm (m2), sq cm, sq ft, sq in, sq yd, hectare (ha), acre, sq km, sq mi
Volumem3 (cu meter)cbm (m3), liter (l, liters), milliliter (ml), pint (pt), quart (qt), gallon (gal), cup, tbsp, tsp, fluid oz (fl oz), cu ft, cu in
Massg (gram)gram (g), milligram (mg), kilogram (kg), metric ton (ton, t), ounce (oz), pound (lb, lbs), stone (st)
Times (second)second (s, sec), minute (min), hour (h, hr, hrs), day (d), week (w), month (mo, $30.436875\text{ d}$), year (yr, $365\text{ d}$)
Data StoragebyteDecimal SI: bit (b), byte (B), KB, MB, GB, TB, PB
Binary IEC: KiB, MiB, GiB, TiB, PiB
Data Transferbps (bits/sec)bps, kbps, Mbps, Gbps
TemperatureK (Kelvin)kelvin (K), celsius (°C, C, degC), fahrenheit (°F, F, degF)
Screen / CSSpx (pixel)pixel (px), point (pt), em (defaults: $1\text{ em} = 16\text{ px}$, $\text{ppi} = 96$)
CurrencyUSD170+ ISO currencies (USD, EUR, GBP, JPY, etc.) and cryptocurrencies (BTC, ETH, SOL)

Multi-Part Unit Concatenation

In everyday language, we rarely express measurements as single fractional decimals; we say "5 feet 11 inches" or "1 hour 30 minutes".

Kalc natively supports Multi-Part Unit Concatenation. Adjacent units sharing the same physical dimension automatically combine into a unified sum without requiring explicit + operators:

text
1 meter 20 cm in inches                         // 47.24 in
5 feet 11 inches in cm                          // 180.34 cm
2 hours 30 mins 15 seconds in hours             // 2.504167 hours
$5 50 cents in cents                            // 550 cents
2 gallons 3 quarts 1 pint in liters             // 10.88 l

Unit Conversions (in, to, ->)

Convert any quantity using in, to, ->, as, or into:

text
100 km/h in mph                                 // 62.14 mph
2.5 TB in GB                                    // 2,500 GB
2.5 TB in GiB                                   // 2,328.31 GiB
180 lbs in kg                                   // 81.65 kg
15 bar in psi                                   // 217.56 psi

Incompatible Dimension Guard

Converting between incompatible physical dimensions is rejected with an inline diagnostic:

text
50 kg in meters                                 // ⚠️ Cannot convert mass (kg) to length (meter)

Data Storage: Decimal (SI) vs. Binary (IEC)

Kalc strictly distinguishes decimal transmission units ($10^3 = 1000$) from binary memory units ($2^{10} = 1024$):

text
1 GB in MB                                      // 1,000 MB (Decimal SI)
1 GiB in MiB                                    // 1,024 MiB (Binary IEC)
1 GB in GiB                                     // 0.931323 GiB

Download Duration Calculations

Kalc reconciles bits and bytes automatically when computing network transfer times:

text
time to download 45 GB at 150 Mbps              // 40 min
time to download 2.4 TB at 1 Gbps               // 5 hr 20 min

Affine Temperature Conversions

Temperature conversions between Celsius, Fahrenheit, and Kelvin require both a scale multiplier and an origin offset:

  • $T_C = T_K - 273.15$
  • $T_F = T_C \times \frac{9}{5} + 32$

Kalc evaluates these exact affine equations:

text
72 °F in °C                                     // 22.22 °C
0 °C in °F                                      // 32 °F
-40 °C in °F                                    // -40 °F
100 °C in K                                     // 373.15 K

Screen & Typography Units

For UI designers and frontend engineers, Kalc bridges CSS and screen typography:

text
24px in em                                      // 1.5 em (Base 16px)
2.5em in px                                     // 40 px
72pt in px                                      // 96 px (96 ppi)

Base em size (default 16px) and display ppi (default 96) can be customized per document or in application preferences.


Disambiguation Rules

To ensure conversational English parses without ambiguity:

  1. in: When followed by a valid unit identifier or radix (in cm, in hex), in acts as the conversion operator. When preceded by a number without a following unit (12 in), it resolves to inches.
  2. m: Standalone after a number resolves to meters (10 m). When prepended to metric unit symbols, it acts as the milli- prefix (mg, ml, mm, ms).
  3. min: Resolves to minutes (15 min). Use min(...) with parentheses for the minimum statistical function.

Culinary Ingredient Density Bridging

Kalc embeds a calibrated culinary density table, allowing volume-to-mass conversions for common kitchen ingredients:

text
250 g butter in cups                            // 1.1 cup
1 cup flour in grams                            // 125 g
2 tbsp olive oil in grams                       // 27.5 g

Supported ingredients: butter, flour, sugar, olive oil, milk, water, honey.

Native macOS Computational Notepad • Pure Swift with Strict Concurrency