diff options
author | Olivier Gayot <og@satcom1.com> | 2017-11-18 15:39:32 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2017-11-19 14:01:08 +0100 |
commit | 0916e5446434acd1a3a8384a3e9b1d935f654140 (patch) | |
tree | fa335f67b8c008c7ffee017fcc91e34c0bc07d7a /number.cpp | |
parent | f5331e02dd2e10c20cb562aa7940747e860411b0 (diff) |
Added multiplication of two numbers
We are using an easy to implemented but extremely slow algorithm to
compute the multiplication of two numbers of size n.
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'number.cpp')
-rw-r--r-- | number.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -92,6 +92,18 @@ number::operator+(const number &n) const return result; } +number +number::operator*(const number &n) const +{ + number result; + + for (number i; i < n; ++i) { + result += *this; + } + + return result; +} + /* }}} */ /* Comparison operators {{{ */ |