Numbat logo

Numbat

Statically typed scientific calculator language with physical dimensions as types and first-class units, with an interactive REPL and unit conversion via ->.

Numbat is a statically typed programming language and scientific calculator for computations involving physical units. Physical dimensions such as Length and Time act as types. Constants and functions can carry optional type annotations that are enforced statically, and types are inferred when annotations are omitted.

Units are first-class. They can be written in several forms (km/h or kilometer/hour, GiB or gibibytes, ° or degree, m² or m^2), and new ones can be defined on the spot with unit pixel. The -> operator converts between compatible units (30 km/h -> mph, 5 in + 2 ft -> cm, 27 weeks -> days), and unit expressions are simplified with heuristics (15 km/h * 30 min = 7.5 km). The standard library covers SI, US Customary, Imperial, Nautical, Astronomical, Atomic and Nuclear units, plus mathematical and physical constants and predefined functions. The parser is strict: bad input gives a descriptive error rather than a guessed result.

Running numbat with no arguments starts a REPL with command history, Ctrl-R search and tab completion. The standard library is itself written in Numbat, so users can extend it through an init.nbt file (for example unit bathtub = 150 L) or replace the prelude module. The assert_eq procedure checks exact or approximate equality at runtime, such as assert_eq(c, 300_000 km/s, 1% × c). Numbat is not a computer algebra system and has no GUI. It suits engineers, scientists and developers who do quick dimension-checked calculations in the terminal. A browser version is available at numbat.dev.

Numbat interactive terminal session

Alternatives & related tools

add a badge to your README

Maintain Numbat? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/numbat.svg)](https://www.trmn.sh/tools/numbat?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/numbat?utm_source=badge"><img src="https://www.trmn.sh/badge/numbat.svg" alt="Featured on trmn" height="20"></a>