From 682df845051dbfb10a00c8795a72faa77c33caf7 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 23 Jun 2012 19:32:19 -0700 Subject: [PATCH] Cleanup, remove FIXMEs. --- src/Amount.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Amount.cpp b/src/Amount.cpp index 3e30ed991..a3831035f 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -527,14 +527,14 @@ STAmount::operator double() const } STAmount operator+(const STAmount& v1, const STAmount& v2) -{ // We can check for precision loss here (value%10)!=0 -// FIXME +{ + if (v1.isZero()) return v2; + if (v2.isZero()) return v1; + v1.throwComparable(v2); if (v1.mIsNative) return STAmount(v1.name, v1.getSNValue() + v2.getSNValue()); - if (v1.isZero()) return v2; - if (v2.isZero()) return v1; int ov1 = v1.mOffset, ov2 = v2.mOffset; int64 vv1 = static_cast(v1.mValue), vv2 = static_cast(v2.mValue); @@ -562,14 +562,12 @@ STAmount operator+(const STAmount& v1, const STAmount& v2) STAmount operator-(const STAmount& v1, const STAmount& v2) { + if (v2.isZero()) return v1; + v1.throwComparable(v2); if (v2.mIsNative) return STAmount(v1.name, v1.getSNValue() - v2.getSNValue()); - if (v2.isZero()) return v1; - if (v1.isZero() || (v2.mOffset > v1.mOffset) ) - throw std::runtime_error("value underflow"); - int ov1 = v1.mOffset, ov2 = v2.mOffset; int64 vv1 = static_cast(v1.mValue), vv2 = static_cast(v2.mValue); if (v1.mIsNegative) vv1 = -vv1;