mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
If an addition or subtraction has a microscopic amount left, make it zero.
This commit is contained in:
@@ -799,7 +799,9 @@ STAmount operator+(const STAmount& v1, const STAmount& v2)
|
||||
// this addition cannot overflow an int64, it can overflow an STAmount and the constructor will throw
|
||||
|
||||
int64 fv = vv1 + vv2;
|
||||
if (fv >= 0)
|
||||
if ((fv >= -10) && (fv <= 10))
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer);
|
||||
else if (fv >= 0)
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
else
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
@@ -834,7 +836,9 @@ STAmount operator-(const STAmount& v1, const STAmount& v2)
|
||||
// this subtraction cannot overflow an int64, it can overflow an STAmount and the constructor will throw
|
||||
|
||||
int64 fv = vv1 - vv2;
|
||||
if (fv >= 0)
|
||||
if ((fv >= -10) && (fv <= 10))
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer);
|
||||
else if (fv >= 0)
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
else
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
|
||||
Reference in New Issue
Block a user