| Crates.io | u24 |
| lib.rs | u24 |
| version | 0.4.0 |
| created_at | 2025-08-02 01:34:02.158669+00 |
| updated_at | 2025-08-17 20:35:24.460226+00 |
| description | An unsigned 24-bit integer type. |
| homepage | https://github.com/orbitinghail/u24 |
| repository | https://github.com/orbitinghail/u24 |
| max_upload_size | |
| id | 1777972 |
| size | 82,359 |
An unsigned 24-bit integer type for Rust.
u32 but enforces 24-bit constraintstd and numBasic construction and usage:
use u24::u24;
// Create u24 values using the macro
let zero = u24!(0);
let small = u24!(42);
let large = u24!(0xFFFFFF); // Maximum value
// Convert from bytes
let from_bytes = u24::from_le_bytes([0x34, 0x12, 0xAB]);
assert_eq!(from_bytes.into_u32(), 0x00_AB1234);
// Convert from u32 with bounds checking
let checked = u24::checked_from_u32(0x123456).unwrap();
let too_big = u24::checked_from_u32(0x01_000000); // None
// Arithmetic operations
let sum = u24!(100) + u24!(200);
let product = u24!(16) * u24!(1024);
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.