32 static const char gDigitsLut[200] = {
33 '0',
'0',
'0',
'1',
'0',
'2',
'0',
'3',
'0',
'4',
'0',
'5',
'0',
'6',
'0',
'7',
'0',
'8',
'0',
'9',
34 '1',
'0',
'1',
'1',
'1',
'2',
'1',
'3',
'1',
'4',
'1',
'5',
'1',
'6',
'1',
'7',
'1',
'8',
'1',
'9',
35 '2',
'0',
'2',
'1',
'2',
'2',
'2',
'3',
'2',
'4',
'2',
'5',
'2',
'6',
'2',
'7',
'2',
'8',
'2',
'9',
36 '3',
'0',
'3',
'1',
'3',
'2',
'3',
'3',
'3',
'4',
'3',
'5',
'3',
'6',
'3',
'7',
'3',
'8',
'3',
'9',
37 '4',
'0',
'4',
'1',
'4',
'2',
'4',
'3',
'4',
'4',
'4',
'5',
'4',
'6',
'4',
'7',
'4',
'8',
'4',
'9',
38 '5',
'0',
'5',
'1',
'5',
'2',
'5',
'3',
'5',
'4',
'5',
'5',
'5',
'6',
'5',
'7',
'5',
'8',
'5',
'9',
39 '6',
'0',
'6',
'1',
'6',
'2',
'6',
'3',
'6',
'4',
'6',
'5',
'6',
'6',
'6',
'7',
'6',
'8',
'6',
'9',
40 '7',
'0',
'7',
'1',
'7',
'2',
'7',
'3',
'7',
'4',
'7',
'5',
'7',
'6',
'7',
'7',
'7',
'8',
'7',
'9',
41 '8',
'0',
'8',
'1',
'8',
'2',
'8',
'3',
'8',
'4',
'8',
'5',
'8',
'6',
'8',
'7',
'8',
'8',
'8',
'9',
42 '9',
'0',
'9',
'1',
'9',
'2',
'9',
'3',
'9',
'4',
'9',
'5',
'9',
'6',
'9',
'7',
'9',
'8',
'9',
'9'
45 inline void u32toa(
char* buffer, uint32_t value) {
47 const uint32_t d1 = (value / 100) << 1;
48 const uint32_t d2 = (value % 100) << 1;
51 *buffer++ = gDigitsLut[d1];
53 *buffer++ = gDigitsLut[d1 + 1];
55 *buffer++ = gDigitsLut[d2];
56 *buffer++ = gDigitsLut[d2 + 1];
58 else if (value < 100000000) {
60 const uint32_t b = value / 10000;
61 const uint32_t c = value % 10000;
63 const uint32_t d1 = (b / 100) << 1;
64 const uint32_t d2 = (b % 100) << 1;
66 const uint32_t d3 = (c / 100) << 1;
67 const uint32_t d4 = (c % 100) << 1;
69 if (value >= 10000000)
70 *buffer++ = gDigitsLut[d1];
72 *buffer++ = gDigitsLut[d1 + 1];
74 *buffer++ = gDigitsLut[d2];
75 *buffer++ = gDigitsLut[d2 + 1];
77 *buffer++ = gDigitsLut[d3];
78 *buffer++ = gDigitsLut[d3 + 1];
79 *buffer++ = gDigitsLut[d4];
80 *buffer++ = gDigitsLut[d4 + 1];
85 const uint32_t a = value / 100000000;
89 const unsigned i = a << 1;
90 *buffer++ = gDigitsLut[i];
91 *buffer++ = gDigitsLut[i + 1];
94 *buffer++ =
'0' +
static_cast<char>(a);
96 const uint32_t b = value / 10000;
97 const uint32_t c = value % 10000;
99 const uint32_t d1 = (b / 100) << 1;
100 const uint32_t d2 = (b % 100) << 1;
102 const uint32_t d3 = (c / 100) << 1;
103 const uint32_t d4 = (c % 100) << 1;
105 *buffer++ = gDigitsLut[d1];
106 *buffer++ = gDigitsLut[d1 + 1];
107 *buffer++ = gDigitsLut[d2];
108 *buffer++ = gDigitsLut[d2 + 1];
109 *buffer++ = gDigitsLut[d3];
110 *buffer++ = gDigitsLut[d3 + 1];
111 *buffer++ = gDigitsLut[d4];
112 *buffer++ = gDigitsLut[d4 + 1];
117 inline void i32toa(
char* buffer, int32_t value) {
118 uint32_t u =
static_cast<uint32_t
>(value);
127 inline void u64toa(
char* buffer, uint64_t value) {
128 if (value < 100000000) {
129 uint32_t v =
static_cast<uint32_t
>(value);
131 const uint32_t d1 = (v / 100) << 1;
132 const uint32_t d2 = (v % 100) << 1;
135 *buffer++ = gDigitsLut[d1];
137 *buffer++ = gDigitsLut[d1 + 1];
139 *buffer++ = gDigitsLut[d2];
140 *buffer++ = gDigitsLut[d2 + 1];
144 const uint32_t b = v / 10000;
145 const uint32_t c = v % 10000;
147 const uint32_t d1 = (b / 100) << 1;
148 const uint32_t d2 = (b % 100) << 1;
150 const uint32_t d3 = (c / 100) << 1;
151 const uint32_t d4 = (c % 100) << 1;
153 if (value >= 10000000)
154 *buffer++ = gDigitsLut[d1];
155 if (value >= 1000000)
156 *buffer++ = gDigitsLut[d1 + 1];
158 *buffer++ = gDigitsLut[d2];
159 *buffer++ = gDigitsLut[d2 + 1];
161 *buffer++ = gDigitsLut[d3];
162 *buffer++ = gDigitsLut[d3 + 1];
163 *buffer++ = gDigitsLut[d4];
164 *buffer++ = gDigitsLut[d4 + 1];
167 else if (value < 10000000000000000) {
168 const uint32_t v0 =
static_cast<uint32_t
>(value / 100000000);
169 const uint32_t v1 =
static_cast<uint32_t
>(value % 100000000);
171 const uint32_t b0 = v0 / 10000;
172 const uint32_t c0 = v0 % 10000;
174 const uint32_t d1 = (b0 / 100) << 1;
175 const uint32_t d2 = (b0 % 100) << 1;
177 const uint32_t d3 = (c0 / 100) << 1;
178 const uint32_t d4 = (c0 % 100) << 1;
180 const uint32_t b1 = v1 / 10000;
181 const uint32_t c1 = v1 % 10000;
183 const uint32_t d5 = (b1 / 100) << 1;
184 const uint32_t d6 = (b1 % 100) << 1;
186 const uint32_t d7 = (c1 / 100) << 1;
187 const uint32_t d8 = (c1 % 100) << 1;
189 if (value >= 1000000000000000)
190 *buffer++ = gDigitsLut[d1];
191 if (value >= 100000000000000)
192 *buffer++ = gDigitsLut[d1 + 1];
193 if (value >= 10000000000000)
194 *buffer++ = gDigitsLut[d2];
195 if (value >= 1000000000000)
196 *buffer++ = gDigitsLut[d2 + 1];
197 if (value >= 100000000000)
198 *buffer++ = gDigitsLut[d3];
199 if (value >= 10000000000)
200 *buffer++ = gDigitsLut[d3 + 1];
201 if (value >= 1000000000)
202 *buffer++ = gDigitsLut[d4];
203 if (value >= 100000000)
204 *buffer++ = gDigitsLut[d4 + 1];
206 *buffer++ = gDigitsLut[d5];
207 *buffer++ = gDigitsLut[d5 + 1];
208 *buffer++ = gDigitsLut[d6];
209 *buffer++ = gDigitsLut[d6 + 1];
210 *buffer++ = gDigitsLut[d7];
211 *buffer++ = gDigitsLut[d7 + 1];
212 *buffer++ = gDigitsLut[d8];
213 *buffer++ = gDigitsLut[d8 + 1];
216 const uint32_t a =
static_cast<uint32_t
>(value / 10000000000000000);
217 value %= 10000000000000000;
220 *buffer++ =
'0' +
static_cast<char>(a);
222 const uint32_t i = a << 1;
223 *buffer++ = gDigitsLut[i];
224 *buffer++ = gDigitsLut[i + 1];
227 *buffer++ =
'0' +
static_cast<char>(a / 100);
229 const uint32_t i = (a % 100) << 1;
230 *buffer++ = gDigitsLut[i];
231 *buffer++ = gDigitsLut[i + 1];
234 const uint32_t i = (a / 100) << 1;
235 const uint32_t j = (a % 100) << 1;
236 *buffer++ = gDigitsLut[i];
237 *buffer++ = gDigitsLut[i + 1];
238 *buffer++ = gDigitsLut[j];
239 *buffer++ = gDigitsLut[j + 1];
242 const uint32_t v0 =
static_cast<uint32_t
>(value / 100000000);
243 const uint32_t v1 =
static_cast<uint32_t
>(value % 100000000);
245 const uint32_t b0 = v0 / 10000;
246 const uint32_t c0 = v0 % 10000;
248 const uint32_t d1 = (b0 / 100) << 1;
249 const uint32_t d2 = (b0 % 100) << 1;
251 const uint32_t d3 = (c0 / 100) << 1;
252 const uint32_t d4 = (c0 % 100) << 1;
254 const uint32_t b1 = v1 / 10000;
255 const uint32_t c1 = v1 % 10000;
257 const uint32_t d5 = (b1 / 100) << 1;
258 const uint32_t d6 = (b1 % 100) << 1;
260 const uint32_t d7 = (c1 / 100) << 1;
261 const uint32_t d8 = (c1 % 100) << 1;
263 *buffer++ = gDigitsLut[d1];
264 *buffer++ = gDigitsLut[d1 + 1];
265 *buffer++ = gDigitsLut[d2];
266 *buffer++ = gDigitsLut[d2 + 1];
267 *buffer++ = gDigitsLut[d3];
268 *buffer++ = gDigitsLut[d3 + 1];
269 *buffer++ = gDigitsLut[d4];
270 *buffer++ = gDigitsLut[d4 + 1];
271 *buffer++ = gDigitsLut[d5];
272 *buffer++ = gDigitsLut[d5 + 1];
273 *buffer++ = gDigitsLut[d6];
274 *buffer++ = gDigitsLut[d6 + 1];
275 *buffer++ = gDigitsLut[d7];
276 *buffer++ = gDigitsLut[d7 + 1];
277 *buffer++ = gDigitsLut[d8];
278 *buffer++ = gDigitsLut[d8 + 1];
284 inline void i64toa(
char* buffer, int64_t value) {
285 uint64_t u =
static_cast<uint64_t
>(value);
void i64toa(char *buffer, int64_t value)
void u32toa(char *buffer, uint32_t value)
void i32toa(char *buffer, int32_t value)
void u64toa(char *buffer, uint64_t value)