forked from btclock/btclock_v3
Add Mow mode notation and setting
This commit is contained in:
parent
239297c26d
commit
d37307cccf
10 changed files with 124 additions and 15 deletions
|
@ -28,7 +28,12 @@ double getSupplyAtBlock(std::uint32_t blockNr)
|
|||
return totalBitcoinInCirculation;
|
||||
}
|
||||
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
||||
{
|
||||
return formatNumberWithSuffix(num, numCharacters, false);
|
||||
}
|
||||
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters, bool mowMode)
|
||||
{
|
||||
static char result[20]; // Adjust size as needed
|
||||
const long long quadrillion = 1000000000000000LL;
|
||||
|
@ -56,30 +61,36 @@ std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
|||
numDouble /= billion;
|
||||
suffix = 'B';
|
||||
}
|
||||
else if (num >= million || numDigits > 6)
|
||||
else if (num >= million || numDigits > 6 || (mowMode && num >= thousand))
|
||||
{
|
||||
numDouble /= million;
|
||||
suffix = 'M';
|
||||
}
|
||||
else if (num >= thousand || numDigits > 3)
|
||||
else if (!mowMode && (num >= thousand || numDigits > 3))
|
||||
{
|
||||
numDouble /= thousand;
|
||||
suffix = 'K';
|
||||
}
|
||||
else
|
||||
else if (!mowMode)
|
||||
{
|
||||
snprintf(result, sizeof(result), "%llu", (unsigned long long)num);
|
||||
// sprintf(result, "%llu", (unsigned long long)num);
|
||||
return result;
|
||||
}
|
||||
else // mowMode is true and num < 1000
|
||||
{
|
||||
numDouble /= million;
|
||||
suffix = 'M';
|
||||
}
|
||||
|
||||
// Add suffix
|
||||
int len = snprintf(result, sizeof(result), "%.0f%c", numDouble, suffix);
|
||||
|
||||
// If there's room, add decimal places
|
||||
// If there's room, add more decimal places
|
||||
if (len < numCharacters)
|
||||
{
|
||||
snprintf(result, sizeof(result), "%.*f%c", numCharacters - len - 1, numDouble, suffix);
|
||||
int restLen = mowMode ? numCharacters - len : numCharacters - len - 1;
|
||||
|
||||
snprintf(result, sizeof(result), "%.*f%c", restLen, numDouble, suffix);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue