lexical_write_integer/
table_decimal.rs

1//! Pre-computed tables for writing decimal strings.
2
3#![cfg(not(feature = "compact"))]
4#![doc(hidden)]
5
6// RADIX^2 TABLES
7// --------------
8
9// Conditionally compile the pre-computed radix**2 tables.
10// These tables take `2 * (value % (radix^2))`, and return
11// two consecutive values corresponding to both digits.
12//
13// Total array storage:
14//  Without radix: ~430 B:
15//      200 u8
16//      11 f32
17//      23 f64
18//  With radix: ~55 KB.
19//      32210 u8
20//      518 f32
21//      2610 f64
22// Provides ~5x performance enhancement.
23//
24// These arrays are cache-friendly, for each BASE[2-36] table,
25// elements can be access sequentially 2-at-a-time, preventing as many
26// cache misses inside inner loops. For example, accessing the two elements
27// for a remainder of `3` for the radix^2 in radix 2 will give you `1` and `1`,
28// at indexes 6 and 7.
29pub const DIGIT_TO_BASE10_SQUARED: [u8; 200] = [
30    b'0', b'0', b'0', b'1', b'0', b'2', b'0', b'3', b'0', b'4', b'0', b'5', b'0', b'6', b'0', b'7',
31    b'0', b'8', b'0', b'9', b'1', b'0', b'1', b'1', b'1', b'2', b'1', b'3', b'1', b'4', b'1', b'5',
32    b'1', b'6', b'1', b'7', b'1', b'8', b'1', b'9', b'2', b'0', b'2', b'1', b'2', b'2', b'2', b'3',
33    b'2', b'4', b'2', b'5', b'2', b'6', b'2', b'7', b'2', b'8', b'2', b'9', b'3', b'0', b'3', b'1',
34    b'3', b'2', b'3', b'3', b'3', b'4', b'3', b'5', b'3', b'6', b'3', b'7', b'3', b'8', b'3', b'9',
35    b'4', b'0', b'4', b'1', b'4', b'2', b'4', b'3', b'4', b'4', b'4', b'5', b'4', b'6', b'4', b'7',
36    b'4', b'8', b'4', b'9', b'5', b'0', b'5', b'1', b'5', b'2', b'5', b'3', b'5', b'4', b'5', b'5',
37    b'5', b'6', b'5', b'7', b'5', b'8', b'5', b'9', b'6', b'0', b'6', b'1', b'6', b'2', b'6', b'3',
38    b'6', b'4', b'6', b'5', b'6', b'6', b'6', b'7', b'6', b'8', b'6', b'9', b'7', b'0', b'7', b'1',
39    b'7', b'2', b'7', b'3', b'7', b'4', b'7', b'5', b'7', b'6', b'7', b'7', b'7', b'8', b'7', b'9',
40    b'8', b'0', b'8', b'1', b'8', b'2', b'8', b'3', b'8', b'4', b'8', b'5', b'8', b'6', b'8', b'7',
41    b'8', b'8', b'8', b'9', b'9', b'0', b'9', b'1', b'9', b'2', b'9', b'3', b'9', b'4', b'9', b'5',
42    b'9', b'6', b'9', b'7', b'9', b'8', b'9', b'9',
43];