MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / AddBinary

Function AddBinary

core/logic/sprintf.cpp:387–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387void AddBinary(char **buf_p, size_t &maxlen, uint64_t val, int width, int flags)
388{
389 char text[64];
390 int digits;
391 char *buf;
392
393 digits = 0;
394 do
395 {
396 if (val & 1)
397 {
398 text[digits++] = '1';
399 }
400 else
401 {
402 text[digits++] = '0';
403 }
404 val >>= 1;
405 } while (val);
406
407 buf = *buf_p;
408
409 if (!(flags & LADJUST))
410 {
411 while (digits < width && maxlen)
412 {
413 *buf++ = (flags & ZEROPAD) ? '0' : ' ';
414 width--;
415 maxlen--;
416 }
417 }
418
419 while (digits-- && maxlen)
420 {
421 *buf++ = text[digits];
422 width--;
423 maxlen--;
424 }
425
426 if (flags & LADJUST)
427 {
428 while ((width-- > 0) && maxlen)
429 {
430 *buf++ = (flags & ZEROPAD) ? '0' : ' ';
431 maxlen--;
432 }
433 }
434
435 *buf_p = buf;
436}
437
438void AddUInt(char **buf_p, size_t &maxlen, uint64_t val, int width, int flags)
439{

Callers 2

gnprintfFunction · 0.85
atcprintfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected