18 int64_t n_abs = (n > 0 ? n : -n);
19 int64_t quotient = n_abs / COIN;
20 int64_t remainder = n_abs % COIN;
21 std::string str =
strprintf(
"%d.%08d", quotient, remainder);
25 for (
int i = str.size() - 1; (str[i] ==
'0' && isdigit(str[i - 2])); --i)
28 str.erase(str.size() - nTrim, nTrim);
31 str.insert((
unsigned int)0, 1,
'-');
32 else if (fPlus && n > 0)
33 str.insert((
unsigned int)0, 1,
'+');
47 const char* p = pszIn;
53 int64_t nMult = CENT * 10;
54 while (isdigit(*p) && (nMult > 0)) {
55 nUnits += nMult * (*p++ -
'0');
64 strWhole.insert(strWhole.end(), *p);
69 if (strWhole.size() > 10)
71 if (nUnits < 0 || nUnits > COIN)
73 int64_t nWhole =
atoi64(strWhole);
74 CAmount nValue = nWhole * COIN + nUnits;
int64_t CAmount
Amount in PIV (Can be negative)
bool ParseMoney(const std::string &str, CAmount &nRet)
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
int64_t atoi64(const char *psz)