Add "round to zero" to subRound/addRound.

This commit is contained in:
JoelKatz
2013-04-02 15:07:40 -07:00
parent 00e2ac8298
commit 116c89fad5

View File

@@ -105,7 +105,9 @@ STAmount STAmount::addRound(const STAmount& v1, const STAmount& v2, bool roundUp
}
int64 fv = vv1 + vv2;
if (fv >= 0)
if ((fv >= -10) && (fv <= -10))
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer);
else if (fv >= 0)
{
uint64 v = static_cast<uint64>(fv);
canonicalizeRound(false, v, ov1, roundUp);
@@ -168,7 +170,9 @@ STAmount STAmount::subRound(const STAmount& v1, const STAmount& v2, bool roundUp
}
int64 fv = vv1 + vv2;
if (fv >= 0)
if ((fv >= -10) && (fv <= -10))
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer);
else if (fv >= 0)
{
uint64 v = static_cast<uint64>(fv);
canonicalizeRound(false, v, ov1, roundUp);