ternaria

An emulation platform for ternary computers.

Every computer you have ever used counts in twos. Ternaria is building the software stack for machines that count in threes — an emulator, a programming language, numerical libraries, and machine learning on ternary hardware.

Early design phase. Architecture decisions are being recorded in the open.

Why base three

Ternaria uses balanced ternary, where each digit — a trit — takes the value −1, 0, or +1. That single change removes whole categories of complexity that binary machines have carried for seventy years.

No sign bit

Negation is a per-digit flip, so it is carry-free and costs one cycle. There is no two's complement, no INT_MIN asymmetry, and no signed/unsigned split — one ADD, one MUL, one CMP instead of two of each.

Truncation is rounding

Chop a balanced-ternary number short and you land on the nearest representable value, always. The discarded tail can never exceed half a unit in the last place. No rounding modes, no guard digits, no round-half-to-even.

Comparison returns one value

Asking whether a < b has three possible answers, and a trit has three states. One instruction returns less, equal, or greater — where binary machines need condition-code pairs to encode three outcomes in two-valued logic.

“Unknown” is a value

The third state carries missing or indeterminate data natively, the way SQL's NULL does — but in hardware. No sentinel values, no parallel mask arrays doubling your memory.

A trit carries log₂3 ≈ 1.585 bits. Ternaria's word is 27 trits — about 42.8 bits — built from 9-trit addressable units.

What we are building

  1. 01

    The emulator

    A ternary machine implemented in software — what QEMU is to binary architectures. A complete instruction set, memory model, and system model, so ternary programs can run today on the hardware you already own.

  2. 02

    Ternex, the language

    A trit-native programming language. Three-valued logic and three-armed conditionals are built into the syntax, because no mainstream language can express a boolean that might be neither true nor false. Ports of Python, C/C++, and Rust will run alongside it.

  3. 03

    Numerics

    Linear algebra built on arithmetic where rounding is exact by construction. The open question we intend to answer honestly: does exact rounding measurably improve accuracy and reproducibility on ill-conditioned problems, or merely simplify the hardware?

  4. 04

    Machine learning

    Machine learning independently converged on ternary weights — −1, 0, +1 — as the sweet spot for quantised networks. We are asking what happens when the hardware's native digit is that weight, rather than something emulated on top of bits.

These are not four isolated demonstrations. The goal is a machine you can actually use — a ternary operating system running at the command line, carrying real numerical and machine-learning workloads on top of it. A parallel experiment aims to translate existing binary programs across, so that a ternary world need not begin from nothing.

Follow along

There is no released code yet. What exists is a public decision register — every architectural choice, the options considered, and the reasoning, including the arguments against us.

Read the roadmap Browse the source