#complex-numbers #big-integer #range-iterator #rational-numbers #bignum #generics

no-std num

A collection of numeric types and traits for Rust, including bigint, complex, rational, range iterators, generic integers, and more!

22 releases

0.4.3 May 8, 2024
0.4.1 Jul 11, 2023
0.4.0 Mar 6, 2021
0.3.1 Nov 3, 2020
0.0.5 Nov 28, 2014

#14 in Rust patterns

Download history 764094/week @ 2024-07-30 834476/week @ 2024-08-06 818784/week @ 2024-08-13 785221/week @ 2024-08-20 751740/week @ 2024-08-27 895914/week @ 2024-09-03 789994/week @ 2024-09-10 736580/week @ 2024-09-17 808581/week @ 2024-09-24 812896/week @ 2024-10-01 807434/week @ 2024-10-08 963202/week @ 2024-10-15 872752/week @ 2024-10-22 813470/week @ 2024-10-29 808469/week @ 2024-11-05 732336/week @ 2024-11-12

3,400,285 downloads per month
Used in 6,720 crates (1,694 directly)

MIT/Apache

13KB

num

crate documentation minimum rustc 1.60 build status

A collection of numeric types and traits for Rust.

This includes new types for big integers, rationals (aka fractions), and complex numbers, new traits for generic programming on numeric properties like Integer, and generic range iterators.

num is a meta-crate, re-exporting items from these sub-crates:

Repository Crate Documentation
num-bigint crate documentation
num-complex crate documentation
num-integer crate documentation
num-iter crate documentation
num-rational crate documentation
num-traits crate documentation
(num-derive) crate documentation

Note: num-derive is listed here for reference, but it's not directly included in num. This is a proc-macro crate for deriving some of num's traits.

Usage

Add this to your Cargo.toml:

[dependencies]
num = "0.4"

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]
version = "0.4"
default-features = false

The num-bigint crate requires the std feature, or the alloc feature may be used instead with Rust 1.36 and later. Other sub-crates may also have limited functionality when used without std.

The libm feature uses pure-Rust floating point implementations in no_std builds, enabling the Float trait and related Complex methods.

The rand feature enables randomization traits in num-bigint and num-complex.

The serde feature enables serialization for types in num-bigint, num-complex, and num-rational.

The num meta-crate no longer supports features to toggle the inclusion of the individual sub-crates. If you need such control, you are recommended to directly depend on your required crates instead.

Releases

Release notes are available in RELEASES.md.

Compatibility

The num crate as a whole is tested for rustc 1.60 and greater.

The num-traits, num-integer, and num-iter crates are individually tested for rustc 1.8 and greater, if you require such older compatibility.

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.

Dependencies

~375–770KB
~16K SLoC