MCPcopy Create free account
hub / github.com/LUX-Core/lux / FormatMoney

Function FormatMoney

src/utilmoneystr.cpp:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

SendMoneyFunction · 0.85
createcontractFunction · 0.85
sendtocontractFunction · 0.85
TxToUnivFunction · 0.85
ProcessBlockFoundFunction · 0.85
PrioritiseTransactionMethod · 0.85
HelpMessageFunction · 0.85
ToStringMethod · 0.85
SelectCoinsMinConfMethod · 0.85
CheckProofMethod · 0.85
CreateCoinStakeMethod · 0.85
createrawtransactionFunction · 0.85

Calls 3

sizeMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68