Native currency scaling.

This commit is contained in:
JoelKatz
2012-04-12 06:06:48 -07:00
parent e42084d496
commit 519a1c9a1d

View File

@@ -312,3 +312,13 @@ STAmount getNeeded(const STAmount& offerOut, const STAmount& offerIn, const STAm
STAmount ret = (needed * offerIn) / offerOut;
return (ret > offerIn) ? offerIn : ret;
}
STAmount convertToDisplayAmount(const STAmount& internalAmount, const STAmount& totalNow, const STAmount& totalInit)
{ // Convert an internal ledger/account quantity of native currency to a display amount
return (internalAmount * totalInit) / totalNow;
}
STAmount convertToInternalAmount(const STAmount& displayAmount, const STAmount& totalNow, const STAmount& totalInit)
{ // Convert a display/request currency amount to an internal amount
return (displayAmount * totalNow) / totalInit;
}