MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / formatDecimal

Function formatDecimal

Sources/Shared/Base/Format.cpp:199–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198 template<typename TUint>
199 char* formatDecimal(char* out, TUint value, std::int32_t digitCount) {
200 unsigned n = static_cast<std::make_unsigned<std::int32_t>::type>(digitCount);
201 while (value >= 100) {
202 n -= 2;
203 std::memcpy(out + n, getTwoDigits(static_cast<unsigned>(value % 100)), 2);
204 value /= 100;
205 }
206 if (value >= 10) {
207 n -= 2;
208 std::memcpy(out + n, getTwoDigits(static_cast<unsigned>(value)), 2);
209 } else {
210 out[--n] = static_cast<char>('0' + value);
211 }
212 return out + n;
213 }
214
215 template<int Bits, typename TUint>
216 constexpr char* formatBase2e(char* out, TUint value, std::int32_t digitCount, bool upperCase = false) {

Callers 1

formatNumberFunction · 0.85

Calls 1

getTwoDigitsFunction · 0.85

Tested by

no test coverage detected