A small library for bit-twiddling.
You can use it by adding this to your Cargo.toml
file:
toml
[dependencies]
twiddle = "1.0"
and adding this to the top of your crate root (main.rs
or lib.rs
):
```rust extern crate twiddle;
use twiddle::Twiddle; ```
```rust extern crate twiddle;
use twiddle::Twiddle;
struct UnpackedF32 { negative: bool, exponent: i16, fraction: u32, }
impl From
fn main() { for f in -5..=5 { let u = UnpackedF32::from(f as f32); println!("{:+} = {}1.{:023b} * 2^{}", f, match u.negative { false => "+", true => "-" }, u.fraction, u.exponent ); } } ```
Licensed under either of
at your option.
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.