A Rust library for representing 12-bit unsigned values. This is primarily useful for implementing Chip-8 assemblers and interpreters safely. The type implements bulk of the standard Rust literal semantics and operators, and much of the documentation is adapted from the u16 intrinsic type.
Add the following to your Cargo.toml
:
toml
[dependencies]
twelve_bit = "0.1"
In addition, and this to your crate root:
```rust
extern crate twelve_bit; ```
Here is an example demonstrating how to interact with the unsigned 12-bit data type U12
.
```rust
extern crate twelve_bit;
use twelve_bit::u12::*;
fn main() { asserteq!(u12![1] + u12![2], u12![3]); asserteq!(u12![4095], U12::maximumvalue()); asserteq!(u12![4095].overflowingadd(u12![1]), (u12![0], true)); asserteq!(u12![4095].overflowing_add(u12![1]), (u12![0], true)); } ```
ShlAssign
and ShrAssign
.U12::from_str_radix()
.Display
, UpperHex
, LowerHex
, Octal
and Binary
.Hash
.Step
.twelve_bit
is distributed under the terms of the MIT license.
See LICENSE for details.