1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*! # `dfkzr` - Dezimalfestkommazahlrechnung
`dfkzr` provides the type [`UDf64`] which represents unsigned decimal fixed point numbers.
The number of integer and fractional digits is configurable with compile-time generic constants.
Values are represented internally using `u64`.
Arithmetic is done on `u64` or `u128`, depending on the operation.
## Features
- Basic unsigned fixed-point arithmetic
- Wrapper types implementing arithmetic traits for convenience, see [`UDf64Checked`] and [`UDf64Saturating`]
- up to 19 effective decimal digits (integer part and fractional combined)
- `#![no_std]` compatible, no runtime dependencies except `core` (except for some tests)
- No heap allocations
- Written in straightforward safe Rust, accompanied by an extensive automated test suite
- `Display`
# Examples
```
use dfkzr::UDf64;
assert_eq!(
UDf64::<4, 2>::ONE.checked_add(UDf64::<4, 2>::ONE),
Ok(UDf64::<4, 2>::try_from_parts(2, 0).unwrap())
);
```
```
use dfkzr::{UDf64, UDf64Checked};
let a: UDf64Checked<6, 3> = UDf64::try_from_parts(1_982, 198).unwrap().into();
let b: UDf64Checked<6, 3> = UDf64::try_from_parts(8_832, 932).unwrap().into();
let c: UDf64Checked<6, 3> = UDf64::try_from_parts(10_815, 130).unwrap().into();
assert_eq!(a + b, Ok(c));
```
```
use dfkzr::udf64;
assert_eq!(udf64!(07, 24).checked_add(udf64!(02, 95)), Ok(udf64!(10, 19)));
```
```
use dfkzr::{udf64, UDf64Saturating};
let a: UDf64Saturating<4, 4> = udf64!(1_483, 0349).into();
let b: UDf64Saturating<4, 4> = udf64!(0_053, 3820).into();
assert_eq!(a * b, UDf64Saturating::<4, 4>::MAX);
```
```
use dfkzr::udf64;
println!("{}", udf64!(0123, 000_789).display()); // prints "123.000789"
```
*/
const PROPTEST_CASES: u32 = 100_000_000;
pub use ArithmeticError;
pub use ;