Numeric traits for generic mathematics in Rust
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-06 20:09:25 +02:00
src Merge pull request #337 from dsemi/master 2025-06-17 21:37:55 +00:00
tests Implement FromPrimitive for NonZero* 2024-09-18 00:01:39 +02:00
.gitignore Update num-macros to Rust master 2015-05-14 10:19:47 -07:00
build.rs Check availability of Saturating 2025-06-17 14:32:18 -07:00
Cargo.toml chore: sync dependencies (monorepo) 2026-04-06 15:21:01 +02:00
LICENSE-APACHE Initial seeding from rust repo 2014-09-16 10:35:35 -07:00
LICENSE-MIT Initial seeding from rust repo 2014-09-16 10:35:35 -07:00
README.md chore: sync dependencies (monorepo) 2026-04-06 20:09:25 +02:00

num-traits

Numeric traits for generic mathematics in Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
num-traits = "0.2"

Features

This crate can be used without the standard library (#![no_std]) by disabling the default std feature. Use this in Cargo.toml:

[dependencies.num-traits]
version = "0.2"
default-features = false
# features = ["libm"]    # <--- Uncomment if you wish to use `Float` and `Real` without `std`

The Float and Real traits are only available when either std or libm is enabled.

The FloatCore trait is always available. MulAdd and MulAddAssign for f32 and f64 also require std or libm, as do implementations of signed and floating- point exponents in Pow.

Releases

Release notes are available in RELEASES.md.

Compatibility

The num-traits crate is tested for rustc 1.60 and greater.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.