# Numbat

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

Stars: 2.8k · Language: Rust · License: Apache-2.0 · Categories: Productivity

- Repository: https://github.com/sharkdp/numbat
- Website: https://numbat.dev
- Page: https://www.trmn.sh/tools/numbat

## Overview

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](https://media.trmn.sh/cached/2d3a36a410c6bc440d3548d0c5d4a03bc9500b31571744b6cf939626fb74dfa7.png)

## Alternatives

- [taskwarrior-tui](https://www.trmn.sh/tools/taskwarrior-tui.md): A terminal user interface for Taskwarrior with vim-like navigation and live filtering capabilities. (Rust, 2.2k stars)
- [kalker](https://www.trmn.sh/tools/kalker.md): Scientific calculator CLI with support for calculus, variables, functions, matrices, and multiple number bases (Rust, 1.9k stars)
- [basalt](https://www.trmn.sh/tools/basalt.md): Terminal user interface (TUI) for managing Obsidian vaults and notes from the command line (Rust, 1.4k stars)
- [outside](https://www.trmn.sh/tools/outside.md): Terminal weather client with multiple output formats including TUI, JSON, and Waybar integration (Rust, 104 stars)
- [pueue](https://www.trmn.sh/tools/pueue.md): Command-line task management tool for sequential and parallel execution of long-running shell commands (Rust, 6.4k stars)

---

Canonical: https://www.trmn.sh/tools/numbat
