diff options
author | Jack Lloyd <[email protected]> | 2018-03-01 16:34:12 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-01 16:34:12 -0500 |
commit | 23e248260ea913227a8d224f64cd9ff592ac8b6b (patch) | |
tree | 42904d2cf064e2609b9fd788018c4ea52f9ef817 | |
parent | 798f62a8ec0b7a6103b518eb439724601a3ba103 (diff) |
Inline some simple BigInt sign handling functions
-rw-r--r-- | src/lib/math/bigint/bigint.cpp | 29 | ||||
-rw-r--r-- | src/lib/math/bigint/bigint.h | 20 |
2 files changed, 17 insertions, 32 deletions
diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index ec0df8f2d..c21ce89fc 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -214,35 +214,6 @@ size_t BigInt::encoded_size(Base base) const } /* -* Set the sign -*/ -void BigInt::set_sign(Sign s) - { - if(is_zero()) - m_signedness = Positive; - else - m_signedness = s; - } - -/* -* Reverse the value of the sign flag -*/ -void BigInt::flip_sign() - { - set_sign(reverse_sign()); - } - -/* -* Return the opposite value of the current sign -*/ -BigInt::Sign BigInt::reverse_sign() const - { - if(sign() == Positive) - return Negative; - return Positive; - } - -/* * Return the negation of this number */ BigInt BigInt::operator-() const diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h index 6e2f8dbde..5092187d9 100644 --- a/src/lib/math/bigint/bigint.h +++ b/src/lib/math/bigint/bigint.h @@ -409,18 +409,32 @@ class BOTAN_PUBLIC_API(2,0) BigInt final /** * @result the opposite sign of the represented integer value */ - Sign reverse_sign() const; + Sign reverse_sign() const + { + if(sign() == Positive) + return Negative; + return Positive; + } /** * Flip the sign of this BigInt */ - void flip_sign(); + void flip_sign() + { + set_sign(reverse_sign()); + } /** * Set sign of the integer * @param sign new Sign to set */ - void set_sign(Sign sign); + void set_sign(Sign sign) + { + if(is_zero()) + m_signedness = Positive; + else + m_signedness = sign; + } /** * @result absolute (positive) value of this |