Crates.io | i48 |
lib.rs | i48 |
version | 1.2.0 |
source | src |
created_at | 2024-08-03 00:59:33.806435 |
updated_at | 2024-08-08 16:31:27.185792 |
description | A Rust library for working with 48-bit integers. |
homepage | |
repository | https://github.com/Chubercik/i48 |
max_upload_size | |
id | 1324013 |
size | 37,013 |
i48
provides a 48-bit signed integer type for Rust, filling the gap between i32
and i64
.
This type may be useful in certain scenarios where 48-bit precision is required but 64 bits would be excessive.
i64
Debug
, Display
, PartialEq
, Eq
, PartialOrd
, Ord
, and Hash
Add this to your Cargo.toml
:
[dependencies]
i48 = "1.2.0"
use i48::i48;
let a: i48 = 1000.into();
let b: i48 = 2000.into();
let c = a + b;
assert_eq!(c.to_i64(), 3000);
i48
is [-140,737,488,355,328; 140,737,488,355,327].i64
.Always use checked arithmetic operations when dealing with untrusted input or when overflow/underflow is a concern.
Contributions are welcome! Please feel free to submit a Pull Request. This project needs more testing and verification.
This project is licensed under the MIT License - see the LICENSE file for details.
This crate came about as a twin project to the i24
crate, one that supports 48-bit signed integers.
Also, check out:
ux
crate, which provides u1
-u127
and i1
-i127
types that should behave as similar as possible to the built in rust types,intx
crate, which provides new integer types with non-standard and fixed bitwidths (such as u24
, i48
, u96
, etc.).