MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FormatMoney

Function FormatMoney

src/utilmoneystr.cpp:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <utilstrencodings.h>
11
12std::string FormatMoney(const CAmount& n)
13{
14 // Note: not using straight sprintf here because we do NOT want
15 // localized number formatting.
16 int64_t n_abs = (n > 0 ? n : -n);
17 int64_t quotient = n_abs/COIN;
18 int64_t remainder = n_abs%COIN;
19 std::string str = strprintf("%d.%08d", quotient, remainder);
20
21 // Right-trim excess zeros before the decimal point:
22 int nTrim = 0;
23 for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i)
24 ++nTrim;
25 if (nTrim)
26 str.erase(str.size()-nTrim, nTrim);
27
28 if (n < 0)
29 str.insert((unsigned int)0, 1, '-');
30 return str;
31}
32
33
34bool ParseMoney(const std::string& str, CAmount& nRet)

Callers 11

PrioritiseTransactionMethod · 0.85
SetupServerArgsFunction · 0.85
AcceptToMemoryPoolWorkerFunction · 0.85
SendMoneyFunction · 0.85
bumpfeeFunction · 0.85
KnapsackSolverFunction · 0.85
AddWalletOptionsMethod · 0.85
CreateTransactionFunction · 0.85
ToStringMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
CheckTxInputsMethod · 0.85

Calls 3

sizeMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68