Accent Fields

Number

The arithmetic family — real numbers, and the digits that are not math.


The arithmetic family. One stored contract — an actual number, not a string of digits — and two variants that differ in whether a fractional part is legal:

Variant The contract Reach for it when
Float any finite number measurements, ratings, rates — quantities you measure
Integer whole numbers only (integer: true) counts, capacities, ordering weights — and money, as cents

What is stored

A number — not a string of digits. "12" sorts before "9" as a string; 12 does not. That single fact is the reason this type exists, and the write boundary enforces it: a value that is not numeric is refused where it enters.

Because it is a number, a query can do arithmetic and ordering with it — rows.sort((a, b) => a.content.capacity - b.content.capacity) — which is the sentence that separates it from a string that happens to hold digits.

Editors

  • text_input — the native input; the usual choice.
  • select — a declared list of numeric options, when only certain values are legal (table sizes: 2, 4, 6, 8). That is an options field whose data type is number.

The digits that are not math

A phone number, a postcode, an ID with leading zeros: these are text, not numbers. The test is whether you would ever add, average, or compare them numerically. 01234 losing its zero is the symptom; the cause is choosing a type for the character set instead of for the operations.