Skip to content

Compact notation

Compact notation expands shorthand values like "1k" or "2.5m" to full numbers when they are typed, pasted or passed in as defaultValue or to setValue(). It is off by default. Set allowCompactNotation to turn it on. Expansion uses string arithmetic, so no precision is lost. A suffix followed by a digit is not expanded: a pasted 1k5 becomes 15. Typed text expands as soon as the suffix is typed, so typing 1k and then 5 gives 10005. Numora removes whitespace before it expands anything, so a pasted 1k 2m is read as 1k2m: the k is followed by a digit and is dropped, and the m expands 12 to 12000000.

SuffixMultiplierExample
k, K×1,000"1k" → "1000"
m, M×1,000,000"1.5m" → "1500000"
b, B×1,000,000,000"2B" → "2000000000"
t, T×1,000,000,000,000"2.5T" → "2500000000000"
import { NumoraInput } from 'numora'

const input = new NumoraInput(container, {
  allowCompactNotation: true
})

Typing 1 then k gives the raw value "1000".