From 519a1c9a1d4ac6f44611b577410bb5bf0e7b52f3 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 12 Apr 2012 06:06:48 -0700 Subject: [PATCH] Native currency scaling. --- src/Amount.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Amount.cpp b/src/Amount.cpp index 0edb6bd44..9e78907a7 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -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; +}