fix/
aliases.rs

1/// Base-2 types.
2pub mod binary {
3    use typenum::U2;
4
5    use Fix;
6
7    pub type UFix8<Exp> = Fix<u8, U2, Exp>;
8    pub type UFix16<Exp> = Fix<u16, U2, Exp>;
9    pub type UFix32<Exp> = Fix<u32, U2, Exp>;
10    pub type UFix64<Exp> = Fix<u64, U2, Exp>;
11    pub type UFixSize<Exp> = Fix<usize, U2, Exp>;
12
13    #[cfg(feature = "i128")]
14    pub type UFix128<Exp> = Fix<u128, U2, Exp>;
15
16    pub type IFix8<Exp> = Fix<i8, U2, Exp>;
17    pub type IFix16<Exp> = Fix<i16, U2, Exp>;
18    pub type IFix32<Exp> = Fix<i32, U2, Exp>;
19    pub type IFix64<Exp> = Fix<i64, U2, Exp>;
20    pub type IFixSize<Exp> = Fix<isize, U2, Exp>;
21
22    #[cfg(feature = "i128")]
23    pub type IFix128<Exp> = Fix<i128, U2, Exp>;
24}
25
26/// Base-10 types.
27pub mod decimal {
28    use typenum::U10;
29
30    use Fix;
31
32    pub type UFix8<Exp> = Fix<u8, U10, Exp>;
33    pub type UFix16<Exp> = Fix<u16, U10, Exp>;
34    pub type UFix32<Exp> = Fix<u32, U10, Exp>;
35    pub type UFix64<Exp> = Fix<u64, U10, Exp>;
36    pub type UFixSize<Exp> = Fix<usize, U10, Exp>;
37
38    #[cfg(feature = "i128")]
39    pub type UFix128<Exp> = Fix<u128, U10, Exp>;
40
41    pub type IFix8<Exp> = Fix<i8, U10, Exp>;
42    pub type IFix16<Exp> = Fix<i16, U10, Exp>;
43    pub type IFix32<Exp> = Fix<i32, U10, Exp>;
44    pub type IFix64<Exp> = Fix<i64, U10, Exp>;
45    pub type IFixSize<Exp> = Fix<isize, U10, Exp>;
46
47    #[cfg(feature = "i128")]
48    pub type IFix128<Exp> = Fix<i128, U10, Exp>;
49}
50
51/// SI prefixes.
52pub mod si {
53    use typenum::{N1, N2, N3, N6, N9, N12, N15, N18, N21, N24};
54    use typenum::{P1, P2, P3, P6, P9, P12, P15, P18, P21, P24};
55    use typenum::{U10, Z0};
56
57    use Fix;
58
59    /** 10<sup>-24</sup> */ pub type Yocto<Bits> = Fix<Bits, U10, N24>;
60    /** 10<sup>-21</sup> */ pub type Zepto<Bits> = Fix<Bits, U10, N21>;
61    /** 10<sup>-18</sup> */ pub type Atto<Bits> = Fix<Bits, U10, N18>;
62    /** 10<sup>-15</sup> */ pub type Femto<Bits> = Fix<Bits, U10, N15>;
63    /** 10<sup>-12</sup> */ pub type Pico<Bits> = Fix<Bits, U10, N12>;
64    /** 10<sup>-9</sup> */ pub type Nano<Bits> = Fix<Bits, U10, N9>;
65    /** 10<sup>-6</sup> */ pub type Micro<Bits> = Fix<Bits, U10, N6>;
66    /** 10<sup>-3</sup> */ pub type Milli<Bits> = Fix<Bits, U10, N3>;
67    /** 10<sup>-2</sup> */ pub type Centi<Bits> = Fix<Bits, U10, N2>;
68    /** 10<sup>-1</sup> */ pub type Deci<Bits> = Fix<Bits, U10, N1>;
69
70    /** 10<sup>0</sup> */ pub type Unit<Bits> = Fix<Bits, U10, Z0>;
71
72    /** 10<sup>1</sup> */ pub type Deca<Bits> = Fix<Bits, U10, P1>;
73    /** 10<sup>2</sup> */ pub type Hecto<Bits> = Fix<Bits, U10, P2>;
74    /** 10<sup>3</sup> */ pub type Kilo<Bits> = Fix<Bits, U10, P3>;
75    /** 10<sup>6</sup> */ pub type Mega<Bits> = Fix<Bits, U10, P6>;
76    /** 10<sup>9</sup> */ pub type Giga<Bits> = Fix<Bits, U10, P9>;
77    /** 10<sup>12</sup> */ pub type Tera<Bits> = Fix<Bits, U10, P12>;
78    /** 10<sup>15</sup> */ pub type Peta<Bits> = Fix<Bits, U10, P15>;
79    /** 10<sup>18</sup> */ pub type Exa<Bits> = Fix<Bits, U10, P18>;
80    /** 10<sup>21</sup> */ pub type Zeta<Bits> = Fix<Bits, U10, P21>;
81    /** 10<sup>24</sup> */ pub type Yotta<Bits> = Fix<Bits, U10, P24>;
82}
83
84/// IEC prefixes.
85pub mod iec {
86    use typenum::{P10, P20, P30, P40, P50, P60, P70, P80};
87    use typenum::{U2, Z0};
88
89    use Fix;
90
91    /** 2<sup>0</sup> */ pub type Unit<Bits> = Fix<Bits, U2, Z0>;
92
93    /** 2<sup>10</sup> */ pub type Kibi<Bits> = Fix<Bits, U2, P10>;
94    /** 2<sup>20</sup> */ pub type Mebi<Bits> = Fix<Bits, U2, P20>;
95    /** 2<sup>30</sup> */ pub type Gibi<Bits> = Fix<Bits, U2, P30>;
96    /** 2<sup>40</sup> */ pub type Tebi<Bits> = Fix<Bits, U2, P40>;
97    /** 2<sup>50</sup> */ pub type Pebi<Bits> = Fix<Bits, U2, P50>;
98    /** 2<sup>60</sup> */ pub type Exbi<Bits> = Fix<Bits, U2, P60>;
99    /** 2<sup>70</sup> */ pub type Zebi<Bits> = Fix<Bits, U2, P70>;
100    /** 2<sup>80</sup> */ pub type Yobi<Bits> = Fix<Bits, U2, P80>;
101}