A statically typed programming language for scientific computations with first class support for physical dimensions and units
命令行科学计算器,支持很多种单位量
https://numbat.dev/

Tamo 7e17ca0dbe apply review comment: Make sure we don't generate broken span when retrieving the span between two other spans 1 tuần trước cách đây
.github cafa2b8cf9 Remove MSRV workflow 4 tháng trước cách đây
assets fae47e8183 Add '\cdot' as additional multiplication operator 1 năm trước cách đây
book 9bbc33dc34 build book 2 tháng trước cách đây
examples ca64bbe995 Merge pull request #757 from ditatompel/master 2 tháng trước cách đây
numbat 7e17ca0dbe apply review comment: Make sure we don't generate broken span when retrieving the span between two other spans 6 ngày trước cách đây
numbat-cli 41960364ed display the backtrace in case of runtime error 6 ngày trước cách đây
numbat-exchange-rates c9786462be Update numbat dependencies 4 tháng trước cách đây
numbat-wasm 38e3bbbf34 make wasm build happy 6 ngày trước cách đây
vscode-extension ed1c5438c4 Correctly handle all types of escaping 4 tháng trước cách đây
.gitignore e1ecd53eb5 Added .DS_Store to gitignore 1 năm trước cách đây
CITATION.cff d4c36dcd9c Bump version 8 tháng trước cách đây
Cargo.lock 91e6d871c7 Fix color=never on errors 6 ngày trước cách đây
Cargo.toml 2588b06b67 Add LTO+strip profile 2 năm trước cách đây
Cross.toml c72a290b6c Add volume mount for /usr/share/zoneinfo 1 năm trước cách đây
LICENSE-APACHE bb1417febb Add license files 2 năm trước cách đây
LICENSE-MIT a9b33fd520 Update LICENSE 1 năm trước cách đây
README.md 477f768ade Add Mads as a maintainer 3 tháng trước cách đây

README.md

**[Try online!] • [Documentation] • [Tutorial] • [Syntax reference] • [Installation] • [Discord] • [Development]** *Numbat* is a statically typed programming language for scientific computations
with first class support for physical dimensions and units.

Key Features

Click to learn more.

Physical dimensions as types

Numbat has a static type system where physical dimensions like `Length` and `Time` act as types. Definitions of constants and functions can optionally contain type annotations that will be statically enforced. If the types are not specified, they will be inferred (`Speed`, `Money` and `Frequency` in the screenshot). See [this article](https://numbat.dev/doc/type-system.html) to learn more about Numbat's type system.
First-class physical units

Numbat is focused on computations with units. Units are therefore treated as first-class citizens. They can be [entered in various ways](https://numbat.dev/doc/unit-notation.html) (`km/h` or `kilometer/hour`, `GiB` or `gibibytes`, `°` or `degree`, `m²` or `m^2`). New units can be [introduced](https://numbat.dev/doc/unit-definitions.html) on the spot (`unit pixel`). Compatible units can be converted easily [using the `->` operator](https://numbat.dev/doc/unit-conversions.html) (`30 km/h -> mph`, `1 mrad -> degree`, `5 in + 2 ft -> cm`, `27 weeks -> days`). And unit expressions are simplified using various heuristics (`15 km/h * 30 min = 7.5 km`).
Comprehensive standard library

Numbat's [standard library](https://numbat.dev/doc/prelude.html) comes with a large number of physical dimensions and units (SI, US Customary, Imperial, Nautical, Astronomical, Atomic, Nuclear, …). See [this reference page](https://numbat.dev/doc/list-units.html) for a complete overview. It also contains a lot of [mathematical and physical constants](https://numbat.dev/doc/list-constants.html) as well as a large range of [pre-defined functions](https://numbat.dev/doc/list-functions.html).
Strict syntax

Numbat's parser never tries to be "smart" on syntactically incorrect input. This means you will either get a (descriptive) error message, or you can trust the result of your calculation.
Excellent error messages

Numbat aims to provide [descriptive and helpful error messages](https://github.com/sharkdp/numbat/blob/master/assets/numbat-error.png).
Interactive terminal

Numbat has been designed for an interactive use-case with small "one off" computations. Opening the `numbat` interpreter without any arguments starts a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) with a familiar readline interface, including all the usual features like a command history, Ctrl-R search or tab completion.
Modular and customizable

The whole system of physical dimensions and units is specified Numbat's standard library, which is [written in the Numbat language](https://github.com/sharkdp/numbat/tree/master/numbat/modules) itself. It is therefore easily extensible by [providing a `init.nbt` file](https://numbat.dev/doc/cli-customization.html). For example, a single line (`unit bathtub = 150 L`) is usually enough to add a new unit. Users can even choose to write their own `prelude` module, allowing for arbitrary modifications to the unit system.
Assertions

With its static type system, Numbat already enforces correctness of your calculations on a physical dimension level. But some checks can only be made at runtime. Numbat provides an `assert_eq` procedure that allows you to check for exact equality using `assert_eq(12 ft, 1 in)` or approximate equality using `assert_eq(c, 300_000 km/s, 1% × c)`. This can be useful to make sure that intermediate results do not change during a restructuring of your calculation.
Non-features

Numbat is a scientific calculator. It's not a computer algebra system that solves differential equations or computes intergrals. Try [WolframAlpha](http://www.wolframalpha.com/) instead.
There is no graphical user interface with buttons like `x²`, `1/x` or `DEG/RAD`. [Qalculate!](http://qalculate.github.io/) is a fantastic tool that supports both text as well as graphical input.
Numbat supports a huge range of physical units. If you need something even more comprehensive, please consider contributing. Or try [GNU units](https://www.gnu.org/software/units/).

 

 

 

 

Installation

See this page for details on how to install the native command-line version of Numbat.

Development

CICD

Run Numbat CLI

cargo run -- <numbat args>

Install the CLI version

cargo install -f --path numbat-cli

Run all tests

cargo test

Working on the prelude

If you are working on Numbat's standard library, it is convenient to point the NUMBAT_MODULES_PATH environment variable to the numbat/modules/ folder. This way, you don't have to recompile Numbat to see your changes.

Alternatively, you can create a symlink from ~/.config/numbat/modules to the numbat/modules/ folder in the repository (see this page for the standard paths on other operating systems).

Contact us

This project is maintained by David Peter and Mads M. Jensen. To contact us, either open a GitHub issue or discussion, or pop into our Discord server.