/src/rust-lexical/lexical-util/src/step.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! The maximum digits that can be held in a u64 for a given radix without |
2 | | //! overflowing. |
3 | | //! |
4 | | //! This is useful for 128-bit division and operations, since it can |
5 | | //! reduces the number of inefficient, non-native operations. |
6 | | //! |
7 | | //! # Generation |
8 | | //! |
9 | | //! See [`etc/step.py`] for the script to generate the divisors and the |
10 | | //! constants, and the division algorithm. |
11 | | //! |
12 | | //! [`etc/step.py`]: https://github.com/Alexhuszagh/rust-lexical/blob/main/lexical-util/etc/step.py |
13 | | |
14 | | #![cfg(any( |
15 | | feature = "parse-floats", |
16 | | feature = "parse-integers", |
17 | | feature = "write-floats", |
18 | | feature = "write-integers", |
19 | | ))] |
20 | | |
21 | | // NOTE: |
22 | | // Fallback radixes use 1 for the value to avoid infinite loops, |
23 | | // but allowing them in `const fn`. |
24 | | |
25 | | /// Get the number of digits that can be always processed without overflowing. |
26 | | /// |
27 | | /// Calculate the number of digits that can always be processed without |
28 | | /// overflowing for a given type, that is, it can process every (positive) value |
29 | | /// in the range `[0, radix^N)` where `N` is the number of digits. |
30 | | /// |
31 | | /// For example, with [`u8`] with radix `10`, we have a maximum value of `255`, |
32 | | /// so we have a min step of `2`: that is, we can always process values from |
33 | | /// `[0, 10^2)` (or `[0, 100)`). |
34 | | #[inline(always)] |
35 | | #[allow(clippy::needless_return)] // reason="required depending on our radix configuration" |
36 | 4.54k | pub const fn min_step(radix: u32, bits: usize, is_signed: bool) -> usize { |
37 | 4.54k | // NOTE: to avoid branching when w don't need it, we use the compile logic |
38 | 4.54k | |
39 | 4.54k | #[cfg(feature = "radix")] |
40 | 4.54k | { |
41 | 4.54k | return match radix { |
42 | 4.54k | 2 => min_step_2(bits, is_signed), |
43 | 4.54k | 3 => min_step_3(bits, is_signed), |
44 | 4.54k | 4 => min_step_4(bits, is_signed), |
45 | 4.54k | 5 => min_step_5(bits, is_signed), |
46 | 4.54k | 6 => min_step_6(bits, is_signed), |
47 | 4.54k | 7 => min_step_7(bits, is_signed), |
48 | 4.54k | 8 => min_step_8(bits, is_signed), |
49 | 4.54k | 9 => min_step_9(bits, is_signed), |
50 | 4.54k | 10 => min_step_10(bits, is_signed), |
51 | 4.54k | 11 => min_step_11(bits, is_signed), |
52 | 4.54k | 12 => min_step_12(bits, is_signed), |
53 | 4.54k | 13 => min_step_13(bits, is_signed), |
54 | 4.54k | 14 => min_step_14(bits, is_signed), |
55 | 4.54k | 15 => min_step_15(bits, is_signed), |
56 | 4.54k | 16 => min_step_16(bits, is_signed), |
57 | 4.54k | 17 => min_step_17(bits, is_signed), |
58 | 4.54k | 18 => min_step_18(bits, is_signed), |
59 | 4.54k | 19 => min_step_19(bits, is_signed), |
60 | 4.54k | 20 => min_step_20(bits, is_signed), |
61 | 4.54k | 21 => min_step_21(bits, is_signed), |
62 | 4.54k | 22 => min_step_22(bits, is_signed), |
63 | 4.54k | 23 => min_step_23(bits, is_signed), |
64 | 4.54k | 24 => min_step_24(bits, is_signed), |
65 | 4.54k | 25 => min_step_25(bits, is_signed), |
66 | 4.54k | 26 => min_step_26(bits, is_signed), |
67 | 4.54k | 27 => min_step_27(bits, is_signed), |
68 | 4.54k | 28 => min_step_28(bits, is_signed), |
69 | 4.54k | 29 => min_step_29(bits, is_signed), |
70 | 4.54k | 30 => min_step_30(bits, is_signed), |
71 | 4.54k | 31 => min_step_31(bits, is_signed), |
72 | 4.54k | 32 => min_step_32(bits, is_signed), |
73 | 4.54k | 33 => min_step_33(bits, is_signed), |
74 | 4.54k | 34 => min_step_34(bits, is_signed), |
75 | 4.54k | 35 => min_step_35(bits, is_signed), |
76 | 4.54k | 36 => min_step_36(bits, is_signed), |
77 | 4.54k | _ => 1, |
78 | 4.54k | }; |
79 | 4.54k | } |
80 | 4.54k | |
81 | 4.54k | #[cfg(all(feature = "power-of-two", not(feature = "radix")))] |
82 | 4.54k | { |
83 | 4.54k | return match radix { |
84 | 4.54k | 2 => min_step_2(bits, is_signed), |
85 | 4.54k | 4 => min_step_4(bits, is_signed), |
86 | 4.54k | 8 => min_step_8(bits, is_signed), |
87 | 4.54k | 10 => min_step_10(bits, is_signed), |
88 | 4.54k | 16 => min_step_16(bits, is_signed), |
89 | 4.54k | 32 => min_step_32(bits, is_signed), |
90 | 4.54k | _ => 1, |
91 | 4.54k | }; |
92 | 4.54k | } |
93 | 4.54k | |
94 | 4.54k | #[cfg(not(feature = "power-of-two"))] |
95 | 4.54k | { |
96 | 4.54k | _ = radix; |
97 | 4.54k | return min_step_10(bits, is_signed); |
98 | 4.54k | } |
99 | 4.54k | } |
100 | | |
101 | | /// Get the maximum number of digits that can be processed without overflowing. |
102 | | /// |
103 | | /// Calculate the number of digits that can be processed without overflowing for |
104 | | /// a given type, that is, it can process at least `radix^N`. This does not |
105 | | /// necessarily mean it can process every value in the range `[0, radix^(N+1))`. |
106 | | /// |
107 | | /// For example, with [`u8`] with radix `10`, we have a maximum value of `255`, |
108 | | /// so we have a max step of `3`: that is, it can process up to 3 digits (`[100, |
109 | | /// 256)`), even if it **cannot** process every 3 digit value (`[256, 1000)`). |
110 | | #[inline(always)] |
111 | | #[allow(clippy::needless_return)] // reason="required depending on our radix configuration" |
112 | | pub const fn max_step(radix: u32, bits: usize, is_signed: bool) -> usize { |
113 | | #[cfg(feature = "radix")] |
114 | | { |
115 | | return match radix { |
116 | | 2 => max_step_2(bits, is_signed), |
117 | | 3 => max_step_3(bits, is_signed), |
118 | | 4 => max_step_4(bits, is_signed), |
119 | | 5 => max_step_5(bits, is_signed), |
120 | | 6 => max_step_6(bits, is_signed), |
121 | | 7 => max_step_7(bits, is_signed), |
122 | | 8 => max_step_8(bits, is_signed), |
123 | | 9 => max_step_9(bits, is_signed), |
124 | | 10 => max_step_10(bits, is_signed), |
125 | | 11 => max_step_11(bits, is_signed), |
126 | | 12 => max_step_12(bits, is_signed), |
127 | | 13 => max_step_13(bits, is_signed), |
128 | | 14 => max_step_14(bits, is_signed), |
129 | | 15 => max_step_15(bits, is_signed), |
130 | | 16 => max_step_16(bits, is_signed), |
131 | | 17 => max_step_17(bits, is_signed), |
132 | | 18 => max_step_18(bits, is_signed), |
133 | | 19 => max_step_19(bits, is_signed), |
134 | | 20 => max_step_20(bits, is_signed), |
135 | | 21 => max_step_21(bits, is_signed), |
136 | | 22 => max_step_22(bits, is_signed), |
137 | | 23 => max_step_23(bits, is_signed), |
138 | | 24 => max_step_24(bits, is_signed), |
139 | | 25 => max_step_25(bits, is_signed), |
140 | | 26 => max_step_26(bits, is_signed), |
141 | | 27 => max_step_27(bits, is_signed), |
142 | | 28 => max_step_28(bits, is_signed), |
143 | | 29 => max_step_29(bits, is_signed), |
144 | | 30 => max_step_30(bits, is_signed), |
145 | | 31 => max_step_31(bits, is_signed), |
146 | | 32 => max_step_32(bits, is_signed), |
147 | | 33 => max_step_33(bits, is_signed), |
148 | | 34 => max_step_34(bits, is_signed), |
149 | | 35 => max_step_35(bits, is_signed), |
150 | | 36 => max_step_36(bits, is_signed), |
151 | | _ => 1, |
152 | | }; |
153 | | } |
154 | | |
155 | | #[cfg(all(feature = "power-of-two", not(feature = "radix")))] |
156 | | { |
157 | | return match radix { |
158 | | 2 => max_step_2(bits, is_signed), |
159 | | 4 => max_step_4(bits, is_signed), |
160 | | 8 => max_step_8(bits, is_signed), |
161 | | 10 => max_step_10(bits, is_signed), |
162 | | 16 => max_step_16(bits, is_signed), |
163 | | 32 => max_step_32(bits, is_signed), |
164 | | _ => 1, |
165 | | }; |
166 | | } |
167 | | |
168 | | #[cfg(not(feature = "power-of-two"))] |
169 | | { |
170 | | _ = radix; |
171 | | return max_step_10(bits, is_signed); |
172 | | } |
173 | | } |
174 | | |
175 | | /// Calculate the number of digits that can be processed without overflowing a |
176 | | /// [`u64`]. Helper function since this is used for 128-bit division. |
177 | | /// |
178 | | /// This is an alias for [`min_step`] with `bits == 64` and `is_signed == |
179 | | /// false`. |
180 | 4.54k | pub const fn u64_step(radix: u32) -> usize { |
181 | 4.54k | min_step(radix, 64, false) |
182 | 4.54k | } |
183 | | |
184 | | // AUTO-GENERATED |
185 | | // These functions were auto-generated by `etc/step.py`. |
186 | | // Do not edit them unless there is a good reason to. |
187 | | // Preferably, edit the source code to generate the constants. |
188 | | // |
189 | | // NOTE: For the fallthrough value for types (in case of adding short |
190 | | // or wider type support in the future), use 1 so it doesn't infinitely |
191 | | // recurse. Under normal circumstances, this will never be called. |
192 | | |
193 | | #[inline(always)] |
194 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
195 | | const fn max_step_2(bits: usize, is_signed: bool) -> usize { |
196 | | match bits { |
197 | | 8 if is_signed => 7, |
198 | | 8 if !is_signed => 8, |
199 | | 16 if is_signed => 15, |
200 | | 16 if !is_signed => 16, |
201 | | 32 if is_signed => 31, |
202 | | 32 if !is_signed => 32, |
203 | | 64 if is_signed => 63, |
204 | | 64 if !is_signed => 64, |
205 | | 128 if is_signed => 127, |
206 | | 128 if !is_signed => 128, |
207 | | _ => 1, |
208 | | } |
209 | | } |
210 | | |
211 | | #[inline(always)] |
212 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
213 | | const fn min_step_2(bits: usize, is_signed: bool) -> usize { |
214 | | match bits { |
215 | | 8 if is_signed => 7, |
216 | | 8 if !is_signed => 8, |
217 | | 16 if is_signed => 15, |
218 | | 16 if !is_signed => 16, |
219 | | 32 if is_signed => 31, |
220 | | 32 if !is_signed => 32, |
221 | | 64 if is_signed => 63, |
222 | | 64 if !is_signed => 64, |
223 | | 128 if is_signed => 127, |
224 | | 128 if !is_signed => 128, |
225 | | _ => 1, |
226 | | } |
227 | | } |
228 | | |
229 | | #[inline(always)] |
230 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
231 | | const fn max_step_3(bits: usize, is_signed: bool) -> usize { |
232 | | match bits { |
233 | | 8 if is_signed => 5, |
234 | | 8 if !is_signed => 6, |
235 | | 16 if is_signed => 10, |
236 | | 16 if !is_signed => 11, |
237 | | 32 if is_signed => 20, |
238 | | 32 if !is_signed => 21, |
239 | | 64 if is_signed => 40, |
240 | | 64 if !is_signed => 41, |
241 | | 128 if is_signed => 81, |
242 | | 128 if !is_signed => 81, |
243 | | _ => 1, |
244 | | } |
245 | | } |
246 | | |
247 | | #[inline(always)] |
248 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
249 | | const fn min_step_3(bits: usize, is_signed: bool) -> usize { |
250 | | match bits { |
251 | | 8 if is_signed => 4, |
252 | | 8 if !is_signed => 5, |
253 | | 16 if is_signed => 9, |
254 | | 16 if !is_signed => 10, |
255 | | 32 if is_signed => 19, |
256 | | 32 if !is_signed => 20, |
257 | | 64 if is_signed => 39, |
258 | | 64 if !is_signed => 40, |
259 | | 128 if is_signed => 80, |
260 | | 128 if !is_signed => 80, |
261 | | _ => 1, |
262 | | } |
263 | | } |
264 | | |
265 | | #[inline(always)] |
266 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
267 | | const fn max_step_4(bits: usize, is_signed: bool) -> usize { |
268 | | match bits { |
269 | | 8 if is_signed => 4, |
270 | | 8 if !is_signed => 4, |
271 | | 16 if is_signed => 8, |
272 | | 16 if !is_signed => 8, |
273 | | 32 if is_signed => 16, |
274 | | 32 if !is_signed => 16, |
275 | | 64 if is_signed => 32, |
276 | | 64 if !is_signed => 32, |
277 | | 128 if is_signed => 64, |
278 | | 128 if !is_signed => 64, |
279 | | _ => 1, |
280 | | } |
281 | | } |
282 | | |
283 | | #[inline(always)] |
284 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
285 | | const fn min_step_4(bits: usize, is_signed: bool) -> usize { |
286 | | match bits { |
287 | | 8 if is_signed => 3, |
288 | | 8 if !is_signed => 4, |
289 | | 16 if is_signed => 7, |
290 | | 16 if !is_signed => 8, |
291 | | 32 if is_signed => 15, |
292 | | 32 if !is_signed => 16, |
293 | | 64 if is_signed => 31, |
294 | | 64 if !is_signed => 32, |
295 | | 128 if is_signed => 63, |
296 | | 128 if !is_signed => 64, |
297 | | _ => 1, |
298 | | } |
299 | | } |
300 | | |
301 | | #[inline(always)] |
302 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
303 | | const fn max_step_5(bits: usize, is_signed: bool) -> usize { |
304 | | match bits { |
305 | | 8 if is_signed => 4, |
306 | | 8 if !is_signed => 4, |
307 | | 16 if is_signed => 7, |
308 | | 16 if !is_signed => 7, |
309 | | 32 if is_signed => 14, |
310 | | 32 if !is_signed => 14, |
311 | | 64 if is_signed => 28, |
312 | | 64 if !is_signed => 28, |
313 | | 128 if is_signed => 55, |
314 | | 128 if !is_signed => 56, |
315 | | _ => 1, |
316 | | } |
317 | | } |
318 | | |
319 | | #[inline(always)] |
320 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
321 | | const fn min_step_5(bits: usize, is_signed: bool) -> usize { |
322 | | match bits { |
323 | | 8 if is_signed => 3, |
324 | | 8 if !is_signed => 3, |
325 | | 16 if is_signed => 6, |
326 | | 16 if !is_signed => 6, |
327 | | 32 if is_signed => 13, |
328 | | 32 if !is_signed => 13, |
329 | | 64 if is_signed => 27, |
330 | | 64 if !is_signed => 27, |
331 | | 128 if is_signed => 54, |
332 | | 128 if !is_signed => 55, |
333 | | _ => 1, |
334 | | } |
335 | | } |
336 | | |
337 | | #[inline(always)] |
338 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
339 | | const fn max_step_6(bits: usize, is_signed: bool) -> usize { |
340 | | match bits { |
341 | | 8 if is_signed => 3, |
342 | | 8 if !is_signed => 4, |
343 | | 16 if is_signed => 6, |
344 | | 16 if !is_signed => 7, |
345 | | 32 if is_signed => 12, |
346 | | 32 if !is_signed => 13, |
347 | | 64 if is_signed => 25, |
348 | | 64 if !is_signed => 25, |
349 | | 128 if is_signed => 50, |
350 | | 128 if !is_signed => 50, |
351 | | _ => 1, |
352 | | } |
353 | | } |
354 | | |
355 | | #[inline(always)] |
356 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
357 | | const fn min_step_6(bits: usize, is_signed: bool) -> usize { |
358 | | match bits { |
359 | | 8 if is_signed => 2, |
360 | | 8 if !is_signed => 3, |
361 | | 16 if is_signed => 5, |
362 | | 16 if !is_signed => 6, |
363 | | 32 if is_signed => 11, |
364 | | 32 if !is_signed => 12, |
365 | | 64 if is_signed => 24, |
366 | | 64 if !is_signed => 24, |
367 | | 128 if is_signed => 49, |
368 | | 128 if !is_signed => 49, |
369 | | _ => 1, |
370 | | } |
371 | | } |
372 | | |
373 | | #[inline(always)] |
374 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
375 | | const fn max_step_7(bits: usize, is_signed: bool) -> usize { |
376 | | match bits { |
377 | | 8 if is_signed => 3, |
378 | | 8 if !is_signed => 3, |
379 | | 16 if is_signed => 6, |
380 | | 16 if !is_signed => 6, |
381 | | 32 if is_signed => 12, |
382 | | 32 if !is_signed => 12, |
383 | | 64 if is_signed => 23, |
384 | | 64 if !is_signed => 23, |
385 | | 128 if is_signed => 46, |
386 | | 128 if !is_signed => 46, |
387 | | _ => 1, |
388 | | } |
389 | | } |
390 | | |
391 | | #[inline(always)] |
392 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
393 | | const fn min_step_7(bits: usize, is_signed: bool) -> usize { |
394 | | match bits { |
395 | | 8 if is_signed => 2, |
396 | | 8 if !is_signed => 2, |
397 | | 16 if is_signed => 5, |
398 | | 16 if !is_signed => 5, |
399 | | 32 if is_signed => 11, |
400 | | 32 if !is_signed => 11, |
401 | | 64 if is_signed => 22, |
402 | | 64 if !is_signed => 22, |
403 | | 128 if is_signed => 45, |
404 | | 128 if !is_signed => 45, |
405 | | _ => 1, |
406 | | } |
407 | | } |
408 | | |
409 | | #[inline(always)] |
410 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
411 | | const fn max_step_8(bits: usize, is_signed: bool) -> usize { |
412 | | match bits { |
413 | | 8 if is_signed => 3, |
414 | | 8 if !is_signed => 3, |
415 | | 16 if is_signed => 5, |
416 | | 16 if !is_signed => 6, |
417 | | 32 if is_signed => 11, |
418 | | 32 if !is_signed => 11, |
419 | | 64 if is_signed => 21, |
420 | | 64 if !is_signed => 22, |
421 | | 128 if is_signed => 43, |
422 | | 128 if !is_signed => 43, |
423 | | _ => 1, |
424 | | } |
425 | | } |
426 | | |
427 | | #[inline(always)] |
428 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
429 | | const fn min_step_8(bits: usize, is_signed: bool) -> usize { |
430 | | match bits { |
431 | | 8 if is_signed => 2, |
432 | | 8 if !is_signed => 2, |
433 | | 16 if is_signed => 5, |
434 | | 16 if !is_signed => 5, |
435 | | 32 if is_signed => 10, |
436 | | 32 if !is_signed => 10, |
437 | | 64 if is_signed => 21, |
438 | | 64 if !is_signed => 21, |
439 | | 128 if is_signed => 42, |
440 | | 128 if !is_signed => 42, |
441 | | _ => 1, |
442 | | } |
443 | | } |
444 | | |
445 | | #[inline(always)] |
446 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
447 | | const fn max_step_9(bits: usize, is_signed: bool) -> usize { |
448 | | match bits { |
449 | | 8 if is_signed => 3, |
450 | | 8 if !is_signed => 3, |
451 | | 16 if is_signed => 5, |
452 | | 16 if !is_signed => 6, |
453 | | 32 if is_signed => 10, |
454 | | 32 if !is_signed => 11, |
455 | | 64 if is_signed => 20, |
456 | | 64 if !is_signed => 21, |
457 | | 128 if is_signed => 41, |
458 | | 128 if !is_signed => 41, |
459 | | _ => 1, |
460 | | } |
461 | | } |
462 | | |
463 | | #[inline(always)] |
464 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
465 | | const fn min_step_9(bits: usize, is_signed: bool) -> usize { |
466 | | match bits { |
467 | | 8 if is_signed => 2, |
468 | | 8 if !is_signed => 2, |
469 | | 16 if is_signed => 4, |
470 | | 16 if !is_signed => 5, |
471 | | 32 if is_signed => 9, |
472 | | 32 if !is_signed => 10, |
473 | | 64 if is_signed => 19, |
474 | | 64 if !is_signed => 20, |
475 | | 128 if is_signed => 40, |
476 | | 128 if !is_signed => 40, |
477 | | _ => 1, |
478 | | } |
479 | | } |
480 | | |
481 | | #[inline(always)] |
482 | | const fn max_step_10(bits: usize, is_signed: bool) -> usize { |
483 | | match bits { |
484 | | 8 if is_signed => 3, |
485 | | 8 if !is_signed => 3, |
486 | | 16 if is_signed => 5, |
487 | | 16 if !is_signed => 5, |
488 | | 32 if is_signed => 10, |
489 | | 32 if !is_signed => 10, |
490 | | 64 if is_signed => 19, |
491 | | 64 if !is_signed => 20, |
492 | | 128 if is_signed => 39, |
493 | | 128 if !is_signed => 39, |
494 | | _ => 1, |
495 | | } |
496 | | } |
497 | | |
498 | | #[inline(always)] |
499 | 4.54k | const fn min_step_10(bits: usize, is_signed: bool) -> usize { |
500 | 0 | match bits { |
501 | 0 | 8 if is_signed => 2, |
502 | 0 | 8 if !is_signed => 2, |
503 | 0 | 16 if is_signed => 4, |
504 | 0 | 16 if !is_signed => 4, |
505 | 0 | 32 if is_signed => 9, |
506 | 0 | 32 if !is_signed => 9, |
507 | 0 | 64 if is_signed => 18, |
508 | 4.54k | 64 if !is_signed => 19, |
509 | 0 | 128 if is_signed => 38, |
510 | 0 | 128 if !is_signed => 38, |
511 | 0 | _ => 1, |
512 | | } |
513 | 4.54k | } |
514 | | |
515 | | #[inline(always)] |
516 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
517 | | const fn max_step_11(bits: usize, is_signed: bool) -> usize { |
518 | | match bits { |
519 | | 8 if is_signed => 3, |
520 | | 8 if !is_signed => 3, |
521 | | 16 if is_signed => 5, |
522 | | 16 if !is_signed => 5, |
523 | | 32 if is_signed => 9, |
524 | | 32 if !is_signed => 10, |
525 | | 64 if is_signed => 19, |
526 | | 64 if !is_signed => 19, |
527 | | 128 if is_signed => 37, |
528 | | 128 if !is_signed => 38, |
529 | | _ => 1, |
530 | | } |
531 | | } |
532 | | |
533 | | #[inline(always)] |
534 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
535 | | const fn min_step_11(bits: usize, is_signed: bool) -> usize { |
536 | | match bits { |
537 | | 8 if is_signed => 2, |
538 | | 8 if !is_signed => 2, |
539 | | 16 if is_signed => 4, |
540 | | 16 if !is_signed => 4, |
541 | | 32 if is_signed => 8, |
542 | | 32 if !is_signed => 9, |
543 | | 64 if is_signed => 18, |
544 | | 64 if !is_signed => 18, |
545 | | 128 if is_signed => 36, |
546 | | 128 if !is_signed => 37, |
547 | | _ => 1, |
548 | | } |
549 | | } |
550 | | |
551 | | #[inline(always)] |
552 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
553 | | const fn max_step_12(bits: usize, is_signed: bool) -> usize { |
554 | | match bits { |
555 | | 8 if is_signed => 2, |
556 | | 8 if !is_signed => 3, |
557 | | 16 if is_signed => 5, |
558 | | 16 if !is_signed => 5, |
559 | | 32 if is_signed => 9, |
560 | | 32 if !is_signed => 9, |
561 | | 64 if is_signed => 18, |
562 | | 64 if !is_signed => 18, |
563 | | 128 if is_signed => 36, |
564 | | 128 if !is_signed => 36, |
565 | | _ => 1, |
566 | | } |
567 | | } |
568 | | |
569 | | #[inline(always)] |
570 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
571 | | const fn min_step_12(bits: usize, is_signed: bool) -> usize { |
572 | | match bits { |
573 | | 8 if is_signed => 1, |
574 | | 8 if !is_signed => 2, |
575 | | 16 if is_signed => 4, |
576 | | 16 if !is_signed => 4, |
577 | | 32 if is_signed => 8, |
578 | | 32 if !is_signed => 8, |
579 | | 64 if is_signed => 17, |
580 | | 64 if !is_signed => 17, |
581 | | 128 if is_signed => 35, |
582 | | 128 if !is_signed => 35, |
583 | | _ => 1, |
584 | | } |
585 | | } |
586 | | |
587 | | #[inline(always)] |
588 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
589 | | const fn max_step_13(bits: usize, is_signed: bool) -> usize { |
590 | | match bits { |
591 | | 8 if is_signed => 2, |
592 | | 8 if !is_signed => 3, |
593 | | 16 if is_signed => 5, |
594 | | 16 if !is_signed => 5, |
595 | | 32 if is_signed => 9, |
596 | | 32 if !is_signed => 9, |
597 | | 64 if is_signed => 18, |
598 | | 64 if !is_signed => 18, |
599 | | 128 if is_signed => 35, |
600 | | 128 if !is_signed => 35, |
601 | | _ => 1, |
602 | | } |
603 | | } |
604 | | |
605 | | #[inline(always)] |
606 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
607 | | const fn min_step_13(bits: usize, is_signed: bool) -> usize { |
608 | | match bits { |
609 | | 8 if is_signed => 1, |
610 | | 8 if !is_signed => 2, |
611 | | 16 if is_signed => 4, |
612 | | 16 if !is_signed => 4, |
613 | | 32 if is_signed => 8, |
614 | | 32 if !is_signed => 8, |
615 | | 64 if is_signed => 17, |
616 | | 64 if !is_signed => 17, |
617 | | 128 if is_signed => 34, |
618 | | 128 if !is_signed => 34, |
619 | | _ => 1, |
620 | | } |
621 | | } |
622 | | |
623 | | #[inline(always)] |
624 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
625 | | const fn max_step_14(bits: usize, is_signed: bool) -> usize { |
626 | | match bits { |
627 | | 8 if is_signed => 2, |
628 | | 8 if !is_signed => 3, |
629 | | 16 if is_signed => 4, |
630 | | 16 if !is_signed => 5, |
631 | | 32 if is_signed => 9, |
632 | | 32 if !is_signed => 9, |
633 | | 64 if is_signed => 17, |
634 | | 64 if !is_signed => 17, |
635 | | 128 if is_signed => 34, |
636 | | 128 if !is_signed => 34, |
637 | | _ => 1, |
638 | | } |
639 | | } |
640 | | |
641 | | #[inline(always)] |
642 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
643 | | const fn min_step_14(bits: usize, is_signed: bool) -> usize { |
644 | | match bits { |
645 | | 8 if is_signed => 1, |
646 | | 8 if !is_signed => 2, |
647 | | 16 if is_signed => 3, |
648 | | 16 if !is_signed => 4, |
649 | | 32 if is_signed => 8, |
650 | | 32 if !is_signed => 8, |
651 | | 64 if is_signed => 16, |
652 | | 64 if !is_signed => 16, |
653 | | 128 if is_signed => 33, |
654 | | 128 if !is_signed => 33, |
655 | | _ => 1, |
656 | | } |
657 | | } |
658 | | |
659 | | #[inline(always)] |
660 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
661 | | const fn max_step_15(bits: usize, is_signed: bool) -> usize { |
662 | | match bits { |
663 | | 8 if is_signed => 2, |
664 | | 8 if !is_signed => 3, |
665 | | 16 if is_signed => 4, |
666 | | 16 if !is_signed => 5, |
667 | | 32 if is_signed => 8, |
668 | | 32 if !is_signed => 9, |
669 | | 64 if is_signed => 17, |
670 | | 64 if !is_signed => 17, |
671 | | 128 if is_signed => 33, |
672 | | 128 if !is_signed => 33, |
673 | | _ => 1, |
674 | | } |
675 | | } |
676 | | |
677 | | #[inline(always)] |
678 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
679 | | const fn min_step_15(bits: usize, is_signed: bool) -> usize { |
680 | | match bits { |
681 | | 8 if is_signed => 1, |
682 | | 8 if !is_signed => 2, |
683 | | 16 if is_signed => 3, |
684 | | 16 if !is_signed => 4, |
685 | | 32 if is_signed => 7, |
686 | | 32 if !is_signed => 8, |
687 | | 64 if is_signed => 16, |
688 | | 64 if !is_signed => 16, |
689 | | 128 if is_signed => 32, |
690 | | 128 if !is_signed => 32, |
691 | | _ => 1, |
692 | | } |
693 | | } |
694 | | |
695 | | #[inline(always)] |
696 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
697 | | const fn max_step_16(bits: usize, is_signed: bool) -> usize { |
698 | | match bits { |
699 | | 8 if is_signed => 2, |
700 | | 8 if !is_signed => 2, |
701 | | 16 if is_signed => 4, |
702 | | 16 if !is_signed => 4, |
703 | | 32 if is_signed => 8, |
704 | | 32 if !is_signed => 8, |
705 | | 64 if is_signed => 16, |
706 | | 64 if !is_signed => 16, |
707 | | 128 if is_signed => 32, |
708 | | 128 if !is_signed => 32, |
709 | | _ => 1, |
710 | | } |
711 | | } |
712 | | |
713 | | #[inline(always)] |
714 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
715 | | const fn min_step_16(bits: usize, is_signed: bool) -> usize { |
716 | | match bits { |
717 | | 8 if is_signed => 1, |
718 | | 8 if !is_signed => 2, |
719 | | 16 if is_signed => 3, |
720 | | 16 if !is_signed => 4, |
721 | | 32 if is_signed => 7, |
722 | | 32 if !is_signed => 8, |
723 | | 64 if is_signed => 15, |
724 | | 64 if !is_signed => 16, |
725 | | 128 if is_signed => 31, |
726 | | 128 if !is_signed => 32, |
727 | | _ => 1, |
728 | | } |
729 | | } |
730 | | |
731 | | #[inline(always)] |
732 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
733 | | const fn max_step_17(bits: usize, is_signed: bool) -> usize { |
734 | | match bits { |
735 | | 8 if is_signed => 2, |
736 | | 8 if !is_signed => 2, |
737 | | 16 if is_signed => 4, |
738 | | 16 if !is_signed => 4, |
739 | | 32 if is_signed => 8, |
740 | | 32 if !is_signed => 8, |
741 | | 64 if is_signed => 16, |
742 | | 64 if !is_signed => 16, |
743 | | 128 if is_signed => 32, |
744 | | 128 if !is_signed => 32, |
745 | | _ => 1, |
746 | | } |
747 | | } |
748 | | |
749 | | #[inline(always)] |
750 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
751 | | const fn min_step_17(bits: usize, is_signed: bool) -> usize { |
752 | | match bits { |
753 | | 8 if is_signed => 1, |
754 | | 8 if !is_signed => 1, |
755 | | 16 if is_signed => 3, |
756 | | 16 if !is_signed => 3, |
757 | | 32 if is_signed => 7, |
758 | | 32 if !is_signed => 7, |
759 | | 64 if is_signed => 15, |
760 | | 64 if !is_signed => 15, |
761 | | 128 if is_signed => 31, |
762 | | 128 if !is_signed => 31, |
763 | | _ => 1, |
764 | | } |
765 | | } |
766 | | |
767 | | #[inline(always)] |
768 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
769 | | const fn max_step_18(bits: usize, is_signed: bool) -> usize { |
770 | | match bits { |
771 | | 8 if is_signed => 2, |
772 | | 8 if !is_signed => 2, |
773 | | 16 if is_signed => 4, |
774 | | 16 if !is_signed => 4, |
775 | | 32 if is_signed => 8, |
776 | | 32 if !is_signed => 8, |
777 | | 64 if is_signed => 16, |
778 | | 64 if !is_signed => 16, |
779 | | 128 if is_signed => 31, |
780 | | 128 if !is_signed => 31, |
781 | | _ => 1, |
782 | | } |
783 | | } |
784 | | |
785 | | #[inline(always)] |
786 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
787 | | const fn min_step_18(bits: usize, is_signed: bool) -> usize { |
788 | | match bits { |
789 | | 8 if is_signed => 1, |
790 | | 8 if !is_signed => 1, |
791 | | 16 if is_signed => 3, |
792 | | 16 if !is_signed => 3, |
793 | | 32 if is_signed => 7, |
794 | | 32 if !is_signed => 7, |
795 | | 64 if is_signed => 15, |
796 | | 64 if !is_signed => 15, |
797 | | 128 if is_signed => 30, |
798 | | 128 if !is_signed => 30, |
799 | | _ => 1, |
800 | | } |
801 | | } |
802 | | |
803 | | #[inline(always)] |
804 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
805 | | const fn max_step_19(bits: usize, is_signed: bool) -> usize { |
806 | | match bits { |
807 | | 8 if is_signed => 2, |
808 | | 8 if !is_signed => 2, |
809 | | 16 if is_signed => 4, |
810 | | 16 if !is_signed => 4, |
811 | | 32 if is_signed => 8, |
812 | | 32 if !is_signed => 8, |
813 | | 64 if is_signed => 15, |
814 | | 64 if !is_signed => 16, |
815 | | 128 if is_signed => 30, |
816 | | 128 if !is_signed => 31, |
817 | | _ => 1, |
818 | | } |
819 | | } |
820 | | |
821 | | #[inline(always)] |
822 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
823 | | const fn min_step_19(bits: usize, is_signed: bool) -> usize { |
824 | | match bits { |
825 | | 8 if is_signed => 1, |
826 | | 8 if !is_signed => 1, |
827 | | 16 if is_signed => 3, |
828 | | 16 if !is_signed => 3, |
829 | | 32 if is_signed => 7, |
830 | | 32 if !is_signed => 7, |
831 | | 64 if is_signed => 14, |
832 | | 64 if !is_signed => 15, |
833 | | 128 if is_signed => 29, |
834 | | 128 if !is_signed => 30, |
835 | | _ => 1, |
836 | | } |
837 | | } |
838 | | |
839 | | #[inline(always)] |
840 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
841 | | const fn max_step_20(bits: usize, is_signed: bool) -> usize { |
842 | | match bits { |
843 | | 8 if is_signed => 2, |
844 | | 8 if !is_signed => 2, |
845 | | 16 if is_signed => 4, |
846 | | 16 if !is_signed => 4, |
847 | | 32 if is_signed => 8, |
848 | | 32 if !is_signed => 8, |
849 | | 64 if is_signed => 15, |
850 | | 64 if !is_signed => 15, |
851 | | 128 if is_signed => 30, |
852 | | 128 if !is_signed => 30, |
853 | | _ => 1, |
854 | | } |
855 | | } |
856 | | |
857 | | #[inline(always)] |
858 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
859 | | const fn min_step_20(bits: usize, is_signed: bool) -> usize { |
860 | | match bits { |
861 | | 8 if is_signed => 1, |
862 | | 8 if !is_signed => 1, |
863 | | 16 if is_signed => 3, |
864 | | 16 if !is_signed => 3, |
865 | | 32 if is_signed => 7, |
866 | | 32 if !is_signed => 7, |
867 | | 64 if is_signed => 14, |
868 | | 64 if !is_signed => 14, |
869 | | 128 if is_signed => 29, |
870 | | 128 if !is_signed => 29, |
871 | | _ => 1, |
872 | | } |
873 | | } |
874 | | |
875 | | #[inline(always)] |
876 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
877 | | const fn max_step_21(bits: usize, is_signed: bool) -> usize { |
878 | | match bits { |
879 | | 8 if is_signed => 2, |
880 | | 8 if !is_signed => 2, |
881 | | 16 if is_signed => 4, |
882 | | 16 if !is_signed => 4, |
883 | | 32 if is_signed => 8, |
884 | | 32 if !is_signed => 8, |
885 | | 64 if is_signed => 15, |
886 | | 64 if !is_signed => 15, |
887 | | 128 if is_signed => 29, |
888 | | 128 if !is_signed => 30, |
889 | | _ => 1, |
890 | | } |
891 | | } |
892 | | |
893 | | #[inline(always)] |
894 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
895 | | const fn min_step_21(bits: usize, is_signed: bool) -> usize { |
896 | | match bits { |
897 | | 8 if is_signed => 1, |
898 | | 8 if !is_signed => 1, |
899 | | 16 if is_signed => 3, |
900 | | 16 if !is_signed => 3, |
901 | | 32 if is_signed => 7, |
902 | | 32 if !is_signed => 7, |
903 | | 64 if is_signed => 14, |
904 | | 64 if !is_signed => 14, |
905 | | 128 if is_signed => 28, |
906 | | 128 if !is_signed => 29, |
907 | | _ => 1, |
908 | | } |
909 | | } |
910 | | |
911 | | #[inline(always)] |
912 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
913 | | const fn max_step_22(bits: usize, is_signed: bool) -> usize { |
914 | | match bits { |
915 | | 8 if is_signed => 2, |
916 | | 8 if !is_signed => 2, |
917 | | 16 if is_signed => 4, |
918 | | 16 if !is_signed => 4, |
919 | | 32 if is_signed => 7, |
920 | | 32 if !is_signed => 8, |
921 | | 64 if is_signed => 15, |
922 | | 64 if !is_signed => 15, |
923 | | 128 if is_signed => 29, |
924 | | 128 if !is_signed => 29, |
925 | | _ => 1, |
926 | | } |
927 | | } |
928 | | |
929 | | #[inline(always)] |
930 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
931 | | const fn min_step_22(bits: usize, is_signed: bool) -> usize { |
932 | | match bits { |
933 | | 8 if is_signed => 1, |
934 | | 8 if !is_signed => 1, |
935 | | 16 if is_signed => 3, |
936 | | 16 if !is_signed => 3, |
937 | | 32 if is_signed => 6, |
938 | | 32 if !is_signed => 7, |
939 | | 64 if is_signed => 14, |
940 | | 64 if !is_signed => 14, |
941 | | 128 if is_signed => 28, |
942 | | 128 if !is_signed => 28, |
943 | | _ => 1, |
944 | | } |
945 | | } |
946 | | |
947 | | #[inline(always)] |
948 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
949 | | const fn max_step_23(bits: usize, is_signed: bool) -> usize { |
950 | | match bits { |
951 | | 8 if is_signed => 2, |
952 | | 8 if !is_signed => 2, |
953 | | 16 if is_signed => 4, |
954 | | 16 if !is_signed => 4, |
955 | | 32 if is_signed => 7, |
956 | | 32 if !is_signed => 8, |
957 | | 64 if is_signed => 14, |
958 | | 64 if !is_signed => 15, |
959 | | 128 if is_signed => 29, |
960 | | 128 if !is_signed => 29, |
961 | | _ => 1, |
962 | | } |
963 | | } |
964 | | |
965 | | #[inline(always)] |
966 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
967 | | const fn min_step_23(bits: usize, is_signed: bool) -> usize { |
968 | | match bits { |
969 | | 8 if is_signed => 1, |
970 | | 8 if !is_signed => 1, |
971 | | 16 if is_signed => 3, |
972 | | 16 if !is_signed => 3, |
973 | | 32 if is_signed => 6, |
974 | | 32 if !is_signed => 7, |
975 | | 64 if is_signed => 13, |
976 | | 64 if !is_signed => 14, |
977 | | 128 if is_signed => 28, |
978 | | 128 if !is_signed => 28, |
979 | | _ => 1, |
980 | | } |
981 | | } |
982 | | |
983 | | #[inline(always)] |
984 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
985 | | const fn max_step_24(bits: usize, is_signed: bool) -> usize { |
986 | | match bits { |
987 | | 8 if is_signed => 2, |
988 | | 8 if !is_signed => 2, |
989 | | 16 if is_signed => 4, |
990 | | 16 if !is_signed => 4, |
991 | | 32 if is_signed => 7, |
992 | | 32 if !is_signed => 7, |
993 | | 64 if is_signed => 14, |
994 | | 64 if !is_signed => 14, |
995 | | 128 if is_signed => 28, |
996 | | 128 if !is_signed => 28, |
997 | | _ => 1, |
998 | | } |
999 | | } |
1000 | | |
1001 | | #[inline(always)] |
1002 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1003 | | const fn min_step_24(bits: usize, is_signed: bool) -> usize { |
1004 | | match bits { |
1005 | | 8 if is_signed => 1, |
1006 | | 8 if !is_signed => 1, |
1007 | | 16 if is_signed => 3, |
1008 | | 16 if !is_signed => 3, |
1009 | | 32 if is_signed => 6, |
1010 | | 32 if !is_signed => 6, |
1011 | | 64 if is_signed => 13, |
1012 | | 64 if !is_signed => 13, |
1013 | | 128 if is_signed => 27, |
1014 | | 128 if !is_signed => 27, |
1015 | | _ => 1, |
1016 | | } |
1017 | | } |
1018 | | |
1019 | | #[inline(always)] |
1020 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1021 | | const fn max_step_25(bits: usize, is_signed: bool) -> usize { |
1022 | | match bits { |
1023 | | 8 if is_signed => 2, |
1024 | | 8 if !is_signed => 2, |
1025 | | 16 if is_signed => 4, |
1026 | | 16 if !is_signed => 4, |
1027 | | 32 if is_signed => 7, |
1028 | | 32 if !is_signed => 7, |
1029 | | 64 if is_signed => 14, |
1030 | | 64 if !is_signed => 14, |
1031 | | 128 if is_signed => 28, |
1032 | | 128 if !is_signed => 28, |
1033 | | _ => 1, |
1034 | | } |
1035 | | } |
1036 | | |
1037 | | #[inline(always)] |
1038 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1039 | | const fn min_step_25(bits: usize, is_signed: bool) -> usize { |
1040 | | match bits { |
1041 | | 8 if is_signed => 1, |
1042 | | 8 if !is_signed => 1, |
1043 | | 16 if is_signed => 3, |
1044 | | 16 if !is_signed => 3, |
1045 | | 32 if is_signed => 6, |
1046 | | 32 if !is_signed => 6, |
1047 | | 64 if is_signed => 13, |
1048 | | 64 if !is_signed => 13, |
1049 | | 128 if is_signed => 27, |
1050 | | 128 if !is_signed => 27, |
1051 | | _ => 1, |
1052 | | } |
1053 | | } |
1054 | | |
1055 | | #[inline(always)] |
1056 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1057 | | const fn max_step_26(bits: usize, is_signed: bool) -> usize { |
1058 | | match bits { |
1059 | | 8 if is_signed => 2, |
1060 | | 8 if !is_signed => 2, |
1061 | | 16 if is_signed => 4, |
1062 | | 16 if !is_signed => 4, |
1063 | | 32 if is_signed => 7, |
1064 | | 32 if !is_signed => 7, |
1065 | | 64 if is_signed => 14, |
1066 | | 64 if !is_signed => 14, |
1067 | | 128 if is_signed => 28, |
1068 | | 128 if !is_signed => 28, |
1069 | | _ => 1, |
1070 | | } |
1071 | | } |
1072 | | |
1073 | | #[inline(always)] |
1074 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1075 | | const fn min_step_26(bits: usize, is_signed: bool) -> usize { |
1076 | | match bits { |
1077 | | 8 if is_signed => 1, |
1078 | | 8 if !is_signed => 1, |
1079 | | 16 if is_signed => 3, |
1080 | | 16 if !is_signed => 3, |
1081 | | 32 if is_signed => 6, |
1082 | | 32 if !is_signed => 6, |
1083 | | 64 if is_signed => 13, |
1084 | | 64 if !is_signed => 13, |
1085 | | 128 if is_signed => 27, |
1086 | | 128 if !is_signed => 27, |
1087 | | _ => 1, |
1088 | | } |
1089 | | } |
1090 | | |
1091 | | #[inline(always)] |
1092 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1093 | | const fn max_step_27(bits: usize, is_signed: bool) -> usize { |
1094 | | match bits { |
1095 | | 8 if is_signed => 2, |
1096 | | 8 if !is_signed => 2, |
1097 | | 16 if is_signed => 4, |
1098 | | 16 if !is_signed => 4, |
1099 | | 32 if is_signed => 7, |
1100 | | 32 if !is_signed => 7, |
1101 | | 64 if is_signed => 14, |
1102 | | 64 if !is_signed => 14, |
1103 | | 128 if is_signed => 27, |
1104 | | 128 if !is_signed => 27, |
1105 | | _ => 1, |
1106 | | } |
1107 | | } |
1108 | | |
1109 | | #[inline(always)] |
1110 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1111 | | const fn min_step_27(bits: usize, is_signed: bool) -> usize { |
1112 | | match bits { |
1113 | | 8 if is_signed => 1, |
1114 | | 8 if !is_signed => 1, |
1115 | | 16 if is_signed => 3, |
1116 | | 16 if !is_signed => 3, |
1117 | | 32 if is_signed => 6, |
1118 | | 32 if !is_signed => 6, |
1119 | | 64 if is_signed => 13, |
1120 | | 64 if !is_signed => 13, |
1121 | | 128 if is_signed => 26, |
1122 | | 128 if !is_signed => 26, |
1123 | | _ => 1, |
1124 | | } |
1125 | | } |
1126 | | |
1127 | | #[inline(always)] |
1128 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1129 | | const fn max_step_28(bits: usize, is_signed: bool) -> usize { |
1130 | | match bits { |
1131 | | 8 if is_signed => 2, |
1132 | | 8 if !is_signed => 2, |
1133 | | 16 if is_signed => 4, |
1134 | | 16 if !is_signed => 4, |
1135 | | 32 if is_signed => 7, |
1136 | | 32 if !is_signed => 7, |
1137 | | 64 if is_signed => 14, |
1138 | | 64 if !is_signed => 14, |
1139 | | 128 if is_signed => 27, |
1140 | | 128 if !is_signed => 27, |
1141 | | _ => 1, |
1142 | | } |
1143 | | } |
1144 | | |
1145 | | #[inline(always)] |
1146 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1147 | | const fn min_step_28(bits: usize, is_signed: bool) -> usize { |
1148 | | match bits { |
1149 | | 8 if is_signed => 1, |
1150 | | 8 if !is_signed => 1, |
1151 | | 16 if is_signed => 3, |
1152 | | 16 if !is_signed => 3, |
1153 | | 32 if is_signed => 6, |
1154 | | 32 if !is_signed => 6, |
1155 | | 64 if is_signed => 13, |
1156 | | 64 if !is_signed => 13, |
1157 | | 128 if is_signed => 26, |
1158 | | 128 if !is_signed => 26, |
1159 | | _ => 1, |
1160 | | } |
1161 | | } |
1162 | | |
1163 | | #[inline(always)] |
1164 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1165 | | const fn max_step_29(bits: usize, is_signed: bool) -> usize { |
1166 | | match bits { |
1167 | | 8 if is_signed => 2, |
1168 | | 8 if !is_signed => 2, |
1169 | | 16 if is_signed => 4, |
1170 | | 16 if !is_signed => 4, |
1171 | | 32 if is_signed => 7, |
1172 | | 32 if !is_signed => 7, |
1173 | | 64 if is_signed => 13, |
1174 | | 64 if !is_signed => 14, |
1175 | | 128 if is_signed => 27, |
1176 | | 128 if !is_signed => 27, |
1177 | | _ => 1, |
1178 | | } |
1179 | | } |
1180 | | |
1181 | | #[inline(always)] |
1182 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1183 | | const fn min_step_29(bits: usize, is_signed: bool) -> usize { |
1184 | | match bits { |
1185 | | 8 if is_signed => 1, |
1186 | | 8 if !is_signed => 1, |
1187 | | 16 if is_signed => 3, |
1188 | | 16 if !is_signed => 3, |
1189 | | 32 if is_signed => 6, |
1190 | | 32 if !is_signed => 6, |
1191 | | 64 if is_signed => 12, |
1192 | | 64 if !is_signed => 13, |
1193 | | 128 if is_signed => 26, |
1194 | | 128 if !is_signed => 26, |
1195 | | _ => 1, |
1196 | | } |
1197 | | } |
1198 | | |
1199 | | #[inline(always)] |
1200 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1201 | | const fn max_step_30(bits: usize, is_signed: bool) -> usize { |
1202 | | match bits { |
1203 | | 8 if is_signed => 2, |
1204 | | 8 if !is_signed => 2, |
1205 | | 16 if is_signed => 4, |
1206 | | 16 if !is_signed => 4, |
1207 | | 32 if is_signed => 7, |
1208 | | 32 if !is_signed => 7, |
1209 | | 64 if is_signed => 13, |
1210 | | 64 if !is_signed => 14, |
1211 | | 128 if is_signed => 26, |
1212 | | 128 if !is_signed => 27, |
1213 | | _ => 1, |
1214 | | } |
1215 | | } |
1216 | | |
1217 | | #[inline(always)] |
1218 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1219 | | const fn min_step_30(bits: usize, is_signed: bool) -> usize { |
1220 | | match bits { |
1221 | | 8 if is_signed => 1, |
1222 | | 8 if !is_signed => 1, |
1223 | | 16 if is_signed => 3, |
1224 | | 16 if !is_signed => 3, |
1225 | | 32 if is_signed => 6, |
1226 | | 32 if !is_signed => 6, |
1227 | | 64 if is_signed => 12, |
1228 | | 64 if !is_signed => 13, |
1229 | | 128 if is_signed => 25, |
1230 | | 128 if !is_signed => 26, |
1231 | | _ => 1, |
1232 | | } |
1233 | | } |
1234 | | |
1235 | | #[inline(always)] |
1236 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1237 | | const fn max_step_31(bits: usize, is_signed: bool) -> usize { |
1238 | | match bits { |
1239 | | 8 if is_signed => 2, |
1240 | | 8 if !is_signed => 2, |
1241 | | 16 if is_signed => 4, |
1242 | | 16 if !is_signed => 4, |
1243 | | 32 if is_signed => 7, |
1244 | | 32 if !is_signed => 7, |
1245 | | 64 if is_signed => 13, |
1246 | | 64 if !is_signed => 13, |
1247 | | 128 if is_signed => 26, |
1248 | | 128 if !is_signed => 26, |
1249 | | _ => 1, |
1250 | | } |
1251 | | } |
1252 | | |
1253 | | #[inline(always)] |
1254 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1255 | | const fn min_step_31(bits: usize, is_signed: bool) -> usize { |
1256 | | match bits { |
1257 | | 8 if is_signed => 1, |
1258 | | 8 if !is_signed => 1, |
1259 | | 16 if is_signed => 3, |
1260 | | 16 if !is_signed => 3, |
1261 | | 32 if is_signed => 6, |
1262 | | 32 if !is_signed => 6, |
1263 | | 64 if is_signed => 12, |
1264 | | 64 if !is_signed => 12, |
1265 | | 128 if is_signed => 25, |
1266 | | 128 if !is_signed => 25, |
1267 | | _ => 1, |
1268 | | } |
1269 | | } |
1270 | | |
1271 | | #[inline(always)] |
1272 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
1273 | | const fn max_step_32(bits: usize, is_signed: bool) -> usize { |
1274 | | match bits { |
1275 | | 8 if is_signed => 2, |
1276 | | 8 if !is_signed => 2, |
1277 | | 16 if is_signed => 3, |
1278 | | 16 if !is_signed => 4, |
1279 | | 32 if is_signed => 7, |
1280 | | 32 if !is_signed => 7, |
1281 | | 64 if is_signed => 13, |
1282 | | 64 if !is_signed => 13, |
1283 | | 128 if is_signed => 26, |
1284 | | 128 if !is_signed => 26, |
1285 | | _ => 1, |
1286 | | } |
1287 | | } |
1288 | | |
1289 | | #[inline(always)] |
1290 | | #[cfg_attr(not(feature = "power-of-two"), allow(dead_code))] |
1291 | | const fn min_step_32(bits: usize, is_signed: bool) -> usize { |
1292 | | match bits { |
1293 | | 8 if is_signed => 1, |
1294 | | 8 if !is_signed => 1, |
1295 | | 16 if is_signed => 3, |
1296 | | 16 if !is_signed => 3, |
1297 | | 32 if is_signed => 6, |
1298 | | 32 if !is_signed => 6, |
1299 | | 64 if is_signed => 12, |
1300 | | 64 if !is_signed => 12, |
1301 | | 128 if is_signed => 25, |
1302 | | 128 if !is_signed => 25, |
1303 | | _ => 1, |
1304 | | } |
1305 | | } |
1306 | | |
1307 | | #[inline(always)] |
1308 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1309 | | const fn max_step_33(bits: usize, is_signed: bool) -> usize { |
1310 | | match bits { |
1311 | | 8 if is_signed => 2, |
1312 | | 8 if !is_signed => 2, |
1313 | | 16 if is_signed => 3, |
1314 | | 16 if !is_signed => 4, |
1315 | | 32 if is_signed => 7, |
1316 | | 32 if !is_signed => 7, |
1317 | | 64 if is_signed => 13, |
1318 | | 64 if !is_signed => 13, |
1319 | | 128 if is_signed => 26, |
1320 | | 128 if !is_signed => 26, |
1321 | | _ => 1, |
1322 | | } |
1323 | | } |
1324 | | |
1325 | | #[inline(always)] |
1326 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1327 | | const fn min_step_33(bits: usize, is_signed: bool) -> usize { |
1328 | | match bits { |
1329 | | 8 if is_signed => 1, |
1330 | | 8 if !is_signed => 1, |
1331 | | 16 if is_signed => 2, |
1332 | | 16 if !is_signed => 3, |
1333 | | 32 if is_signed => 6, |
1334 | | 32 if !is_signed => 6, |
1335 | | 64 if is_signed => 12, |
1336 | | 64 if !is_signed => 12, |
1337 | | 128 if is_signed => 25, |
1338 | | 128 if !is_signed => 25, |
1339 | | _ => 1, |
1340 | | } |
1341 | | } |
1342 | | |
1343 | | #[inline(always)] |
1344 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1345 | | const fn max_step_34(bits: usize, is_signed: bool) -> usize { |
1346 | | match bits { |
1347 | | 8 if is_signed => 2, |
1348 | | 8 if !is_signed => 2, |
1349 | | 16 if is_signed => 3, |
1350 | | 16 if !is_signed => 4, |
1351 | | 32 if is_signed => 7, |
1352 | | 32 if !is_signed => 7, |
1353 | | 64 if is_signed => 13, |
1354 | | 64 if !is_signed => 13, |
1355 | | 128 if is_signed => 25, |
1356 | | 128 if !is_signed => 26, |
1357 | | _ => 1, |
1358 | | } |
1359 | | } |
1360 | | |
1361 | | #[inline(always)] |
1362 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1363 | | const fn min_step_34(bits: usize, is_signed: bool) -> usize { |
1364 | | match bits { |
1365 | | 8 if is_signed => 1, |
1366 | | 8 if !is_signed => 1, |
1367 | | 16 if is_signed => 2, |
1368 | | 16 if !is_signed => 3, |
1369 | | 32 if is_signed => 6, |
1370 | | 32 if !is_signed => 6, |
1371 | | 64 if is_signed => 12, |
1372 | | 64 if !is_signed => 12, |
1373 | | 128 if is_signed => 24, |
1374 | | 128 if !is_signed => 25, |
1375 | | _ => 1, |
1376 | | } |
1377 | | } |
1378 | | |
1379 | | #[inline(always)] |
1380 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1381 | | const fn max_step_35(bits: usize, is_signed: bool) -> usize { |
1382 | | match bits { |
1383 | | 8 if is_signed => 2, |
1384 | | 8 if !is_signed => 2, |
1385 | | 16 if is_signed => 3, |
1386 | | 16 if !is_signed => 4, |
1387 | | 32 if is_signed => 7, |
1388 | | 32 if !is_signed => 7, |
1389 | | 64 if is_signed => 13, |
1390 | | 64 if !is_signed => 13, |
1391 | | 128 if is_signed => 25, |
1392 | | 128 if !is_signed => 25, |
1393 | | _ => 1, |
1394 | | } |
1395 | | } |
1396 | | |
1397 | | #[inline(always)] |
1398 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1399 | | const fn min_step_35(bits: usize, is_signed: bool) -> usize { |
1400 | | match bits { |
1401 | | 8 if is_signed => 1, |
1402 | | 8 if !is_signed => 1, |
1403 | | 16 if is_signed => 2, |
1404 | | 16 if !is_signed => 3, |
1405 | | 32 if is_signed => 6, |
1406 | | 32 if !is_signed => 6, |
1407 | | 64 if is_signed => 12, |
1408 | | 64 if !is_signed => 12, |
1409 | | 128 if is_signed => 24, |
1410 | | 128 if !is_signed => 24, |
1411 | | _ => 1, |
1412 | | } |
1413 | | } |
1414 | | |
1415 | | #[inline(always)] |
1416 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1417 | | const fn max_step_36(bits: usize, is_signed: bool) -> usize { |
1418 | | match bits { |
1419 | | 8 if is_signed => 2, |
1420 | | 8 if !is_signed => 2, |
1421 | | 16 if is_signed => 3, |
1422 | | 16 if !is_signed => 4, |
1423 | | 32 if is_signed => 6, |
1424 | | 32 if !is_signed => 7, |
1425 | | 64 if is_signed => 13, |
1426 | | 64 if !is_signed => 13, |
1427 | | 128 if is_signed => 25, |
1428 | | 128 if !is_signed => 25, |
1429 | | _ => 1, |
1430 | | } |
1431 | | } |
1432 | | |
1433 | | #[inline(always)] |
1434 | | #[cfg_attr(not(feature = "radix"), allow(dead_code))] |
1435 | | const fn min_step_36(bits: usize, is_signed: bool) -> usize { |
1436 | | match bits { |
1437 | | 8 if is_signed => 1, |
1438 | | 8 if !is_signed => 1, |
1439 | | 16 if is_signed => 2, |
1440 | | 16 if !is_signed => 3, |
1441 | | 32 if is_signed => 5, |
1442 | | 32 if !is_signed => 6, |
1443 | | 64 if is_signed => 12, |
1444 | | 64 if !is_signed => 12, |
1445 | | 128 if is_signed => 24, |
1446 | | 128 if !is_signed => 24, |
1447 | | _ => 1, |
1448 | | } |
1449 | | } |