MCPcopy Create free account
hub / github.com/baldurk/renderdoc / PrintFloat0

Function PrintFloat0

renderdoc/strings/utf8printf.cpp:440–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440void PrintFloat0(bool e, bool f, bool a, bool uppercaseDigits, FormatterParams formatter,
441 char prepend, char *&output, size_t &actualsize, char *end)
442{
443 int numwidth = 0;
444
445 if(a && formatter.Precision == FormatterParams::NoPrecision)
446 formatter.Precision = 0;
447
448 if(a)
449 numwidth = formatter.Precision + 1 + 5; // 0 plus precision plus 0xp+0
450 else if(e)
451 numwidth = formatter.Precision + 1 + 4; // 0 plus precision plus e+00
452 else if(f || formatter.Flags & AlternateForm)
453 numwidth = formatter.Precision + 1; // 0 plus precision
454 else
455 numwidth = 1;
456
457 // alternate form means . is included even if no digits after .
458 if(((e || f || a) && formatter.Precision > 0) || (formatter.Flags & AlternateForm))
459 numwidth++; // .
460
461 if(!e && !f && !a && (formatter.Flags & AlwaysDecimal))
462 {
463 numwidth += 2; // .0
464 }
465
466 // sign space
467 if(prepend)
468 numwidth++;
469
470 int padlen = 0;
471
472 if(formatter.Width != FormatterParams::NoWidth && formatter.Width > numwidth)
473 padlen = formatter.Width - numwidth;
474
475 if(formatter.Flags & PadZeroes)
476 {
477 if(a)
478 appendstring(output, actualsize, end, uppercaseDigits ? "0X" : "0x");
479
480 if(prepend)
481 addchar(output, actualsize, end, prepend);
482 addchars(output, actualsize, end, size_t(padlen), '0');
483 }
484 else if(padlen > 0 && (formatter.Flags & LeftJustify) == 0)
485 {
486 addchars(output, actualsize, end, size_t(padlen), ' ');
487 if(prepend)
488 addchar(output, actualsize, end, prepend);
489
490 if(a)
491 appendstring(output, actualsize, end, uppercaseDigits ? "0X" : "0x");
492 }
493 else
494 {
495 if(prepend)
496 addchar(output, actualsize, end, prepend);
497

Callers 1

PrintFloatFunction · 0.85

Calls 3

appendstringFunction · 0.85
addcharFunction · 0.85
addcharsFunction · 0.85

Tested by

no test coverage detected