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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
macro_rules! consts_impl {
() => {
impl<const N: usize> UnsignedDecimal<N> {
/// **N**ot **A** **N**umber value. More about [`NaN`](crate#special-values).
pub const NAN: Self = Self::new(Decimal::NAN);
/// Infinity (∞). More about [`±Infinity`](crate#special-values).
pub const INFINITY: Self = Self::new(Decimal::INFINITY);
/// The smallest value that can be represented by this decimal type (0).
pub const MIN: Self = Self::ZERO;
/// The largest value that can be represented by this decimal type (2<sup>N</sup> − 1)×10<sup>32'768</sup>.
pub const MAX: Self = Self::new(Decimal::MAX);
/// The smallest positive, normalized value that this type can represent.
pub const MIN_POSITIVE: Self = Self::new(Decimal::MIN_POSITIVE);
/// [Machine epsilon] value.
///
/// This is the difference between `1.0` and the next larger representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
pub const EPSILON: Self = Self::new(Decimal::EPSILON);
consts_impl!(CONSTS ZERO 0, ONE 1, TWO 2, THREE 3, FOUR 4, FIVE 5, SIX 6, SEVEN 7, EIGHT 8, NINE 9, TEN 10);
/// Euler's number (e).
pub const E: Self = Self::new(Decimal::E);
/// Archimedes’ constant (π).
pub const PI: Self = Self::new(Decimal::PI);
/// The full circle constant (τ)
///
/// Equal to 2π.
pub const TAU: Self = Self::new(Decimal::TAU);
/// 1/π.
pub const FRAC_1_PI: Self = Self::new(Decimal::FRAC_1_PI);
/// 2/π.
pub const FRAC_2_PI: Self = Self::new(Decimal::FRAC_2_PI);
/// π/2.
pub const FRAC_PI_2: Self = Self::new(Decimal::FRAC_PI_2);
/// π/3.
pub const FRAC_PI_3: Self = Self::new(Decimal::FRAC_PI_3);
/// π/4.
pub const FRAC_PI_4: Self = Self::new(Decimal::FRAC_PI_4);
/// π/6.
pub const FRAC_PI_6: Self = Self::new(Decimal::FRAC_PI_6);
/// π/8.
pub const FRAC_PI_8: Self = Self::new(Decimal::FRAC_PI_8);
/// 2/sqrt(π).
pub const FRAC_2_SQRT_PI: Self = Self::new(Decimal::FRAC_2_SQRT_PI);
/// ln(2).
pub const LN_2: Self = Self::new(Decimal::LN_2);
/// ln(10).
pub const LN_10: Self = Self::new(Decimal::LN_10);
/// log<sub>2</sub>(e).
pub const LOG2_E: Self = Self::new(Decimal::LOG2_E);
/// log<sub>10</sub>(e).
pub const LOG10_E: Self = Self::new(Decimal::LOG10_E);
/// sqrt(2).
pub const SQRT_2: Self = Self::new(Decimal::SQRT_2);
/// 1/sqrt(2).
pub const FRAC_1_SQRT_2: Self = Self::new(Decimal::FRAC_1_SQRT_2);
/// log<sub>10</sub>(2).
pub const LOG10_2: Self = Self::new(Decimal::LOG10_2);
/// log<sub>2</sub>(10).
pub const LOG2_10: Self = Self::new(Decimal::LOG2_10);
}
};
(CONSTS $($name: ident $num: literal), *) => {
$(
#[doc = concat!("The value of `", $num, "` represented by this decimal type.")]
pub const $name: Self = Self::new(Decimal::$name);
)*
}
}
pub(crate) use consts_impl;