MCPcopy Create free account
hub / github.com/crownengine/crown / toStringUnsigned

Function toStringUnsigned

3rdparty/bx/src/dtoa.cpp:507–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505
506 template<typename Ty>
507 int32_t toStringUnsigned(char* _dst, int32_t _max, Ty _value, uint32_t _base, char _separator)
508 {
509 char data[32];
510 int32_t len = 0;
511
512 if (_base > 16
513 || _base < 2)
514 {
515 return 0;
516 }
517
518 uint32_t count = 1;
519
520 do
521 {
522 const Ty rem = _value % _base;
523 _value /= _base;
524 if (rem < 10)
525 {
526 data[len++] = char('0' + rem);
527 }
528 else
529 {
530 data[len++] = char('a' + rem - 10);
531 }
532
533 if ('\0' != _separator
534 && 0 == count%3
535 && 0 != _value)
536 {
537 data[len++] = _separator;
538 }
539
540 ++count;
541 }
542 while (0 != _value);
543
544 if (_max < len + 1)
545 {
546 return 0;
547 }
548
549 reverse(data, len);
550
551 memCopy(_dst, data, len);
552 _dst[len] = '\0';
553 return int32_t(len);
554 }
555
556 int32_t toString(char* _dst, int32_t _max, uint32_t _value, uint32_t _base, char _separator)
557 {

Callers 1

toStringFunction · 0.85

Calls 2

reverseFunction · 0.85
memCopyFunction · 0.85

Tested by

no test coverage detected