approx
Approximate floating point equality comparisons and assertions for Rust
Repository Health
Technical Analysis
approx is a small, foundational Rust crate for comparing floating point numbers for approximate equality. Because binary floats rarely compare exactly equal, it provides relative, absolute, and ULP (units in the last place) based comparison strategies so numeric code and tests can express meaningful tolerances.
The crate ships ergonomic assertion macros such as assert_relative_eq!, assert_abs_diff_eq!, and assert_ulps_eq!, along with the AbsDiffEq, RelativeEq, and UlpsEq traits that downstream types can implement. It is an extremely widely used dependency across the Rust scientific and graphics ecosystem, distributed under the Apache-2.0 license.
What You Get
- Assertion macros:
assert_relative_eq!,assert_abs_diff_eq!,assert_ulps_eq! - The
AbsDiffEq,RelativeEq, andUlpsEqcomparison traits - Configurable epsilon, max relative, and max ULP tolerances
- A
no_std-friendly, dependency-light implementation
Common Use Cases
- Writing unit tests that compare computed floats within a tolerance
- Validating results of numerical and geometric algorithms
- Implementing approximate equality for custom math types
- Comparing vectors and matrices in graphics or physics code
Under The Hood
Architecture - approx is built around three core traits — AbsDiffEq, RelativeEq, and UlpsEq — each parameterized by an epsilon type and default tolerances. Assertion macros expand into calls against these traits, and blanket/derived implementations cover primitive floats and slices while letting user types opt in.
Tech Stack - Pure Rust with optional num-complex and num-traits integration, no_std support, and a minimum rustc of 1.36; distributed as the approx crate on crates.io.
Code Quality - A compact, thoroughly documented codebase with docs.rs coverage, CI test workflows, and 30 contributors; its long track record and ~132M downloads reflect strong reliability.
API Design - The macro plus trait design is highly ergonomic: comparisons read naturally, tolerances are set fluently via builder-style macro arguments, and extending support to new types is a matter of implementing a small trait.
Used by 3 apps in this directory
Fyrox
Game Development
A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts
ParadeDB
Search · Databases · Analytics
Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.
Qdrant
Databases · AI Development · Search
Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.