#integer #big #uint #fixed-size #integer-arithmetic #unsigned-integer #tetsy

no-std uint-crate

Tetsy Common Large Fixed-Size Integer Arithmetic

Show the crate…

4 releases

0.9.1 Jun 8, 2021
0.9.0 Feb 18, 2021
0.9.0-alpha Mar 10, 2021
0.8.1 Feb 20, 2021

#2 in #tetsy

Download history 225/week @ 2023-12-08 650/week @ 2023-12-15 593/week @ 2023-12-22 280/week @ 2023-12-29 485/week @ 2024-01-05 627/week @ 2024-01-12 513/week @ 2024-01-19 498/week @ 2024-01-26 415/week @ 2024-02-02 513/week @ 2024-02-09 510/week @ 2024-02-16 371/week @ 2024-02-23 477/week @ 2024-03-01 577/week @ 2024-03-08 485/week @ 2024-03-15 336/week @ 2024-03-22

1,948 downloads per month
Used in 234 crates (4 directly)

MIT/Apache

53KB
1.5K SLoC

uint-crate

Description

Provides facilities to construct big unsigned integer types which use no allocations (stack-based, fixed bit length). If you want to use a predefined U128, U256 or U512 type, take a look at the tetsy-primitive-types or vapory-types crate.

The focus on the provided big unsigned integer types is performance and cross-platform availability. Support a very similar API as the built-in primitive integer types.

Usage

In your Cargo.toml paste

uint = "0.9.0"

Import the macro

use uint_crate::construct_uint;

If you're using pre-edition Rust in your main file

#[macro_use]
extern crate uint_crate;

Construct your own big unsigned integer type as follows.

// U1024 with 1024 bits consisting of 16 x 64-bit words
construct_uint! {
	pub struct U1024(16);
}

Tests

Basic tests

cargo test --release

Basic tests + property tests

cargo test --release --features=quickcheck

Benchmark tests

cargo bench

Fuzz tests

see fuzz README.md

Crate Features

  • std: Use Rust's standard library.
    • Enables byteorder/std, rustc-hex/std
    • Enabled by default.
  • quickcheck: Enable quickcheck-style property testing
    • Use with cargo test --release --features=quickcheck.
  • arbitrary: Allow for creation of an uint object from random unstructured input for use with fuzzers that use the arbitrary crate.
    • Disabled by default.

Dependencies

~155–350KB