diff options
author | Jack Lloyd <[email protected]> | 2018-12-05 10:48:32 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-05 10:48:32 -0500 |
commit | 5609fbc43c2277947732377c598942ce72aab64a (patch) | |
tree | f964e57f8e6bb7e6d6f112b4c8743f3cbbddab77 | |
parent | 73c846b452b4e716e078820d7a8bce9f6054b5fd (diff) |
Use BigInt::cond_flip_sign
-rw-r--r-- | src/lib/math/bigint/big_ops2.cpp | 4 | ||||
-rw-r--r-- | src/lib/math/bigint/big_ops3.cpp | 4 | ||||
-rw-r--r-- | src/lib/math/bigint/divide.cpp | 3 |
3 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp index 6e858d272..0dc3c7715 100644 --- a/src/lib/math/bigint/big_ops2.cpp +++ b/src/lib/math/bigint/big_ops2.cpp @@ -176,9 +176,7 @@ BigInt& BigInt::rev_sub(const word y[], size_t y_sw, secure_vector<word>& ws) const int32_t relative_size = bigint_sub_abs(ws.data(), data(), x_sw, y, y_sw); - if(relative_size > 0) - this->flip_sign(); - + this->cond_flip_sign(relative_size > 0); this->swap_reg(ws); return (*this); diff --git a/src/lib/math/bigint/big_ops3.cpp b/src/lib/math/bigint/big_ops3.cpp index 7a4c8f215..e6c745dca 100644 --- a/src/lib/math/bigint/big_ops3.cpp +++ b/src/lib/math/bigint/big_ops3.cpp @@ -63,8 +63,8 @@ BigInt operator*(const BigInt& x, const BigInt& y) workspace.data(), workspace.size()); } - if(x_sw && y_sw && x.sign() != y.sign()) - z.flip_sign(); + z.cond_flip_sign(x_sw > 0 && y_sw > 0 && x.sign() != y.sign()); + return z; } diff --git a/src/lib/math/bigint/divide.cpp b/src/lib/math/bigint/divide.cpp index 98df233e3..be47c6b5d 100644 --- a/src/lib/math/bigint/divide.cpp +++ b/src/lib/math/bigint/divide.cpp @@ -20,8 +20,7 @@ namespace { */ void sign_fixup(const BigInt& x, const BigInt& y, BigInt& q, BigInt& r) { - if(x.sign() != y.sign()) - q.flip_sign(); + q.cond_flip_sign(x.sign() != y.sign()); if(x.is_negative() && r.is_nonzero()) { |