summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <og@satcom1.com>2017-11-18 13:54:29 +0100
committerOlivier Gayot <og@satcom1.com>2017-11-19 14:01:08 +0100
commita78c788171d45057406b571846e55541eef49688 (patch)
tree97b6ccf86e5b0995bcb4626085ae9d35f524b8fa
parentc029a456f410ef45f4803bc7e209fbab81b3c42a (diff)
Made use of 32bits integer instead of 64bits
This will allow multiplication to hold the result of the multiplication of two 32 bits integer in a 64 bits integer. Signed-off-by: Olivier Gayot <og@satcom1.com>
-rw-r--r--number.cpp6
-rw-r--r--number.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/number.cpp b/number.cpp
index acd60fd..bd05dbf 100644
--- a/number.cpp
+++ b/number.cpp
@@ -20,7 +20,7 @@ number::to_hex_string() const
/* If more operands are present, successive ones must be padded. */
ss << std::setfill('0');
- ss << std::setw(16);
+ ss << std::setw(8);
}
return ss.str();
@@ -71,10 +71,10 @@ number::operator+(const number &n) const
result._operands.push_back(n1 + n2 + (carry ? 1 : 0));
- if (carry && (n1 == UINT64_MAX)) {
+ if (carry && (n1 == UINT32_MAX)) {
carry = true;
} else {
- carry = ((UINT64_MAX - n1 - (carry ? 1 : 0)) < n2);
+ carry = ((UINT32_MAX - n1 - (carry ? 1 : 0)) < n2);
}
++it;
diff --git a/number.h b/number.h
index 8489453..97817ac 100644
--- a/number.h
+++ b/number.h
@@ -76,7 +76,7 @@ public:
private:
/* First item is the least significant. */
- std::list<std::uint64_t> _operands;
+ std::list<std::uint32_t> _operands;
};
std::ostream &operator<<(std::ostream &, const number &);