MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / append_exponent

Function append_exponent

dependencies/json/json.hpp:15336–15375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15334JSON_HEDLEY_NON_NULL(1)
15335JSON_HEDLEY_RETURNS_NON_NULL
15336inline char* append_exponent(char* buf, int e)
15337{
15338 JSON_ASSERT(e > -1000);
15339 JSON_ASSERT(e < 1000);
15340
15341 if (e < 0)
15342 {
15343 e = -e;
15344 *buf++ = '-';
15345 }
15346 else
15347 {
15348 *buf++ = '+';
15349 }
15350
15351 auto k = static_cast<std::uint32_t>(e);
15352 if (k < 10)
15353 {
15354 // Always print at least two digits in the exponent.
15355 // This is for compatibility with printf("%g").
15356 *buf++ = '0';
15357 *buf++ = static_cast<char>('0' + k);
15358 }
15359 else if (k < 100)
15360 {
15361 *buf++ = static_cast<char>('0' + k / 10);
15362 k %= 10;
15363 *buf++ = static_cast<char>('0' + k);
15364 }
15365 else
15366 {
15367 *buf++ = static_cast<char>('0' + k / 100);
15368 k %= 100;
15369 *buf++ = static_cast<char>('0' + k / 10);
15370 k %= 10;
15371 *buf++ = static_cast<char>('0' + k);
15372 }
15373
15374 return buf;
15375}
15376
15377/*!
15378@brief prettify v = buf * 10^decimal_exponent

Callers 1

format_bufferFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected