MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / Uint32ToStr

Function Uint32ToStr

include/LightGBM/utils/common.h:324–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324inline static void Uint32ToStr(uint32_t value, char* buffer) {
325 const char kDigitsLut[200] = {
326 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
327 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
328 '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
329 '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
330 '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
331 '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
332 '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
333 '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
334 '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
335 '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'
336 };
337 unsigned digit = CountDecimalDigit32(value);
338 buffer += digit;
339 *buffer = '\0';
340
341 while (value >= 100) {
342 const unsigned i = (value % 100) << 1;
343 value /= 100;
344 *--buffer = kDigitsLut[i + 1];
345 *--buffer = kDigitsLut[i];
346 }
347
348 if (value < 10) {
349 *--buffer = static_cast<char>(value) + '0';
350 } else {
351 const unsigned i = value << 1;
352 *--buffer = kDigitsLut[i + 1];
353 *--buffer = kDigitsLut[i];
354 }
355}
356
357inline static void Int32ToStr(int32_t value, char* buffer) {
358 uint32_t u = static_cast<uint32_t>(value);

Callers 2

Int32ToStrFunction · 0.70
operator()Method · 0.70

Calls 1

CountDecimalDigit32Function · 0.70

Tested by

no test coverage detected