CLI tool
printfn/fend avatar
printfn/fend

fend: a unit-aware calculator that keeps variables and refuses to lose precision

Arbitrary-precision unit-aware calculator

1,056 stars75 forksRustMIT

At a glance

What is it?
fend is a Rust calculator that does arbitrary-precision rational arithmetic with units, supports complex numbers, dice rolls and bases from 2 to 36, and ships as a CLI, a web app, a WebAssembly build and a Telegram bot.
Who is it for?
fend fits someone who does unit-heavy arithmetic by hand, an engineer checking a conversion, a tabletop player rolling dice, or a developer who wants unit-aware evaluation in their own program through the core library. It is a poor fit if you want a scientific calculator with a physical keypad or a graphing interface, since it is a text REPL with a web wrapper.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What the calculator actually does

fend is an arbitrary-precision unit-aware calculator, and the feature list is the quickest way to understand what that means in practice.

Arbitrary-precision arithmetic using rational numbers is the foundation. A calculation like a third of a metre is not approximated as 0.3333 metres, it is kept as one third and only converted at the point where you ask for a unit. That is the difference between a calculator that gives you 30.48 cm for a foot and one that gives you 30.48 cm because the exact value happens to be that.

Full support for complex numbers sits on top of that, so the trigonometric functions and the imaginary unit compose:

code
> cos (pi/4) + i * (sin (pi/4))
approx. 0.7071067811 + 0.7071067811i

Note the word approx. The result is not a clean fraction, so it is displayed as an approximation rather than rounded to a fixed number of digits, which is the honest thing to do with a transcendental function and is the behaviour you would want in a tool that is otherwise exact.

There are D&D-style dice rolls, variables, binary, octal, hexadecimal and all other bases between 2 and 36, and trigonometric functions. It also supports lambda calculus, which is an unusual entry in a calculator's feature list and is the clearest signal that the author enjoys the type theory side of the language.

The one that makes it different from every other calculator is unit tracking, with support for SI, US and UK customary and many historical units. That is the feature the rest of the design serves.

Units, variables, and the REPL that keeps state

The interface is a REPL. Once fend is installed, you run fend to start a session:

code
$ fend
> 1 ft to cm
30.48 cm
>

A conversion is just an expression, and the unit is part of the expression. So the calculator can be used as a converter without any special mode.

Variables work the same way, and this is where the REPL earns its keep. You assign a value with a name, and the name stays available:

code
> temperature = 30 °C
30 °C
> temperature to °F
86 °F

The temperature is remembered, and asking for it in Fahrenheit later reuses the stored value. You can also write the value and the target unit on one line, as in 5'10" to cm, which returns 177.8 cm. That form, with feet and inches written as an imperial height, is the case the tool is actually good at, and it shows the difference between this and a plain calculator with a units library bolted on: the syntax for a compound quantity is the same syntax as for a plain expression.

Bases work the way you would expect, with a prefix selecting the radix:

code
> 0b1001 + 3
0b1100

> 0xffff to decimal
65535

So arithmetic happens in the base you wrote it in, and converting to decimal is a separate operation that does not change the working base for subsequent input.

Dice are handled as a function call:

code
> roll d20
8
> roll 4d6
17

Note that roll 4d6 returns a single number, 17, which is the sum of four six-sided dice rather than a list of the individual rolls. Whether the individual results are visible is not something the examples here answer.

The CLI shortcuts are described as Emacs-style, so the editing behaviour inside the REPL is what you would expect from someone who lives in Emacs, and the manual at printfn.github.io/fend/documentation/ is where the details live.

One Rust workspace, three crates, and a size-first release profile

The repository is a Cargo workspace with three members, cli, core and wasm, and the version is 1.5.8 with edition 2024.

The split is the interesting part. The core member is published on its own as fend-core, and the workspace dependency list names it explicitly with both a path and a version. The cli member is the terminal application, and the wasm member is the WebAssembly build. That is why the README links a separate downloads badge for fend-core on crates.io: the core is a library other programs can depend on, and the download counts for the two are tracked separately.

The release profile in the workspace manifest is tuned for size rather than speed:

toml
[profile.release]
lto = true
opt-level = "z" # small code size
strip = "symbols"

Link time optimisation on, opt-level z for the smallest output, and symbols stripped. For a calculator that people install from a package manager or download as a single binary, a small binary is worth more than a few percent of runtime, and the reasoning is explicit in the comment.

The repository has more directories than the three crates, because the project ships many things beyond the compiler. There is a cli directory, a core directory and a wasm directory as the workspace members, plus a contrib directory, a documentation directory, an icon directory, a telegram-bot directory, a web directory, and both windows-msix and windows-wix directories for Windows packaging. The web directory is the web interface, the telegram-bot directory is the Telegram bot, and the two windows directories are the two different Windows installer formats.

There is also a .cargo directory, a .rustfmt.toml, a .codecov.yml, a .git-blame-ignore-revs and a CHANGELOG.md, which is the usual set for a Rust project that formats and tests itself in CI.

The same calculator, on the web and in your own program

The distribution list is unusually wide for a calculator, and it tells you that the author wanted this to be reachable everywhere.

The install table lists Homebrew with brew install fend, MacPorts with sudo port install fend, the AUR for Arch with yay -S aur/fend-bin, AOSC OS with oma install fend, Xbps for Void Linux with xbps-install fend, Nix either by adding nixpkgs.fend to your config or ephemerally with nix-shell -p fend, Cargo with cargo install fend, Windows Package Manager with winget install fend, Chocolatey with choco install fend, Scoop with scoop install fend, and Pkgx with pkgx fend.

Alternatively you can manually download the latest stable binaries from the releases page.

Then the packages list, which goes beyond package managers. There is an NPM fend-wasm package, a fend-wasm-web package, and a fend-wasm-nodejs package, so the same calculator can be embedded in a browser page or run inside Node, and a Telegram Bot so you can use it from a chat. The web interface at printfn.github.io/fend is the hosted version of the WASM build, which is the same design as the Docker route on many other projects: compile once to WebAssembly, serve the static output anywhere.

For a developer, the most useful of these is fend-core. It is the library the CLI is built on, published separately on crates.io, and it is how you would put unit-aware evaluation into your own Rust program rather than shelling out to the binary. The three examples in the README of other projects using fend point the same way: MicroPad, Fendesk, metasearch2, FendApp and Asleh all consume the calculator somehow, and the README invites pull requests to add more.

The manual is at printfn.github.io/fend/documentation/ and covers the language, the units and the CLI in more detail than the README does.

What it is not, and where the limits are

The first limitation is the interface. fend is a text REPL with a web wrapper, and there is no graphing, no matrix editor and no scientific keypad. If you want a calculator to hand to someone who has never used a terminal, this is not it, and the web interface is still a text box.

The second limitation is the unit coverage, and it is the one to check before committing. The documentation says SI, US and UK customary and many historical units, and the word many is doing work there. A unit-aware calculator is only as useful as the units it knows, and if your work involves a unit that is not in the set, there is no way to define it yourself, because nothing in the feature list suggests a way to introduce a new unit.

The third limitation is that the exactness cuts both ways. Rational arithmetic means a result can be an unwieldy fraction, and the display has to decide what to do with it. The trigonometric example shows an approximation marker, and the conversions in the examples come out as exact decimals, which suggests the output is formatted to a fixed number of digits. So the arbitrary-precision claim is about the internal computation, not about the printed output, and a value like one third divided by seven will not print as a fraction.

The fourth is the ordinary one for a single-maintainer project. The repository is not archived, the last push was on 2026-08-28, and the releases are v1.5.8 from 2026-01-24, v1.5.7 from 2025-07-14 and v1.5.6 from 2025-03-14. The project is MIT licensed with a LICENSE.md.

The interesting note in the release history is the version scheme rather than the dates. The CLI and the core library are versioned together from the workspace package, and the download badge for fend-core is separate from the one for fend, so the two crates share a version but are counted separately, which means a change to the core library is a change to the CLI's version too.

Editorial conclusion

fend fits someone who does unit-heavy arithmetic by hand, an engineer checking a conversion, a tabletop player rolling dice, or a developer who wants unit-aware evaluation in their own program through the core library. It is a poor fit if you want a scientific calculator with a physical keypad or a graphing interface, since it is a text REPL with a web wrapper. Before adopting, try the web interface at printfn.github.io/fend to confirm the unit set covers the units you work in, and if you are embedding it, use fend-core directly rather than the CLI, since the workspace separates the core library from the front end.

Frequently asked questions

What is fend and what makes it different from a normal calculator?

fend is an arbitrary-precision unit-aware calculator written in Rust. It does rational arithmetic, tracks units across SI, US, UK customary and many historical units, supports complex numbers, variables, bases from 2 to 36, dice rolls and lambda calculus, with an Emacs-style CLI.

How do I install fend?

Through a package manager: brew install fend for Homebrew, cargo install fend for Cargo, yay -S aur/fend-bin for Arch, nix-shell -p fend for Nix, winget install fend for Windows Package Manager, choco install fend for Chocolatey, and there are also MacPorts, AOSC OS, Xbps, Scoop and Pkgx entries. You can also download the latest stable binaries from the releases page.

How do I use variables in fend?

Assign a value to a name and it stays available in the session, for example temperature = 30 °C, after which you can ask temperature to °F and get 86 °F. You can also convert in one line, as in 5'10" to cm, which returns 177.8 cm.

Can I use fend in my own program?

Yes, through fend-core, which is published separately on crates.io and is the library the CLI is built on. There are also NPM packages, fend-wasm, fend-wasm-web and fend-wasm-nodejs, a web interface, and a Telegram bot. The Cargo workspace has three members, cli, core and wasm, all versioned at 1.5.8.

Does fend run in a web browser?

Yes, there is a web interface at printfn.github.io/fend, and it is built from the WebAssembly member of the Cargo workspace. The repository also publishes npm packages for the wasm build for web and for Node, plus a Telegram bot for using the calculator from chat.

Official sources

  1. License: MIT
  2. printfn/fend on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/printfn-fend.svg)](https://hysenlabs.com/projects/printfn-fend)

Was this useful?