MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / append_exponent

Function append_exponent

native/thirdpart/json/json.hpp:13572–13611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13570JSON_HEDLEY_NON_NULL(1)
13571JSON_HEDLEY_RETURNS_NON_NULL
13572inline char* append_exponent(char* buf, int e)
13573{
13574 assert(e > -1000);
13575 assert(e < 1000);
13576
13577 if (e < 0)
13578 {
13579 e = -e;
13580 *buf++ = '-';
13581 }
13582 else
13583 {
13584 *buf++ = '+';
13585 }
13586
13587 auto k = static_cast<std::uint32_t>(e);
13588 if (k < 10)
13589 {
13590 // Always print at least two digits in the exponent.
13591 // This is for compatibility with printf("%g").
13592 *buf++ = '0';
13593 *buf++ = static_cast<char>('0' + k);
13594 }
13595 else if (k < 100)
13596 {
13597 *buf++ = static_cast<char>('0' + k / 10);
13598 k %= 10;
13599 *buf++ = static_cast<char>('0' + k);
13600 }
13601 else
13602 {
13603 *buf++ = static_cast<char>('0' + k / 100);
13604 k %= 100;
13605 *buf++ = static_cast<char>('0' + k / 10);
13606 k %= 10;
13607 *buf++ = static_cast<char>('0' + k);
13608 }
13609
13610 return buf;
13611}
13612
13613/*!
13614@brief prettify v = buf * 10^decimal_exponent

Callers 1

format_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected