5 releases
0.3.1 | Jan 12, 2023 |
---|---|
0.3.0 | Jan 12, 2023 |
0.2.2 | Sep 23, 2022 |
0.2.1 | Sep 1, 2022 |
0.2.0 | Sep 1, 2022 |
#2197 in Algorithms
11KB
247 lines
Simple Arithmetic for Byte-like Objects
Vec<u8>
object that implements a subset of basic arithmetic, namely addition and integer
multiplication.
Multiplication is implemented as multiplicative addition.
use byte_arithmetic::Base256;
assert_eq!(
Base256::new(vec![1,2,3]) + Base256::new(vec![1,2,3]),
Base256::new(vec![2,4,6])
);
assert_eq!(
Base256::new(vec![1,2,3]) * 3,
Base256::new(vec![3,6,9])
);
Dependencies
~0.7–1.3MB
~29K SLoC