fix/
aliases.rs

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