Abaco — Math Engine for Rust
Italian/Spanish: abacus
Abaco is a Rust math engine providing expression evaluation and unit conversion. Shared library crate for the AGNOS ecosystem.
Pure Rust, zero unsafe — minimal dependencies, 99%+ test coverage.
Features
| Module | Description |
|---|---|
core |
Value types (Integer, Float, Fraction, Complex, Text), Unit, UnitCategory (14 categories), Currency |
eval |
Tokenizer, recursive descent parser, 28+ math functions, variables, scientific notation, percentage shorthand |
units |
Unit registry with 100+ built-in units, HashMap-indexed O(1) lookups, SI + IEC data sizes |
ai |
Natural language math parsing, calculation history (feature-gated) |
Quick Start
[]
= "0.22"
# With natural language parsing:
# abaco = { version = "0.22", features = ["ai"] }
use ;
// Evaluate expressions
let eval = new;
let result = eval.eval.unwrap;
assert_eq!;
let result = eval.eval.unwrap;
assert_eq!;
// Percentage shorthand
let result = eval.eval.unwrap;
assert_eq!;
// Variables
let mut eval = new;
eval.set_variable;
let result = eval.eval.unwrap;
assert_eq!;
// Unit conversion
let registry = new;
let r = registry.convert.unwrap;
assert!;
// SI and IEC data sizes
let r = registry.convert.unwrap;
assert!;
Feature Flags
| Feature | Default | Description | Extra deps |
|---|---|---|---|
ai |
no | Natural language math parsing, calculation history | reqwest, tokio |
full |
— | All optional features | (same as ai) |
Consumers
| Project | Uses |
|---|---|
| Abacus | Desktop calculator GUI, CLI, REPL, MCP tools |
| Impetus | Unit conversions, expression evaluation for physics simulation |
Supported Functions (28+)
Trig: sin, cos, tan, asin, acos, atan, atan2 Hyperbolic: sinh, cosh, tanh, asinh, acosh, atanh Logarithmic: log (log10), ln, log2 Rounding: ceil, floor, round, trunc, fract Other: sqrt, abs, exp, sign/sgn, deg, rad, min, max, pow
Unit Categories (14)
Length, Mass, Temperature, Time, DataSize (SI + IEC), Speed, Area, Volume, Energy, Pressure, Angle, Frequency, Force, Power
100+ units with case-insensitive lookup, plural forms, and case-sensitive symbol distinction (mW vs MW).
License
AGPL-3.0-only