bitint
A bit-integer library for Rust. bitint
s are like primitive integer types, but
their logical width is measured in bits.
This crate provides the UBitint
trait and 128 types named U1
through U128
that implement it. Each type wraps the smallest primitive unsigned integer type
that can contain it. The types that are not the same width as their primitive
type impose a validity constraint---the value is represented in the least
significant bits and the upper bits are always clear.
Demo
// Recommended, but not required.
use *;
// Use the bitint! macro to write a bitint literal. Underscores are permitted
// anywhere in a Rust literal and are encouraged for readability.
let seven = bitint!;
// Use the #[bitint_literals] attribute macro to write bitint literals anywhere
// inside an item. Here the item is a function, but it can also be useful on an
// impl block or inline module.
# demo;
;
Crate features
- unchecked_math - Enables the
unchecked_*
methods on unsignedbitint
types. Requires a nightly Rust compiler.