From 471186ab6e721fed603871f385d9590a69878de3 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 19 Nov 2017 13:12:12 +0100 Subject: Allowed construction of number from 64-bits-wide integer Signed-off-by: Olivier Gayot --- number.cpp | 15 ++++++++++++--- number.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/number.cpp b/number.cpp index 497cf64..fa62b00 100644 --- a/number.cpp +++ b/number.cpp @@ -2,9 +2,18 @@ #include #include "number.h" -number::number(std::uint32_t n): - _operands{n} -{ } +number::number(std::uint64_t n) +{ + if (n == 0) { + return; + } + + _operands.push_back(n & UINT32_MAX); + + if (n > UINT32_MAX) { + _operands.push_back(n >> 32); + } +} /* Type Conversion {{{ */ diff --git a/number.h b/number.h index 16fcea6..f68299d 100644 --- a/number.h +++ b/number.h @@ -13,7 +13,7 @@ public: number &operator=(const number &) = default; - number(std::uint32_t); + number(std::uint64_t); /** * \brief Return a hexadecimal string representation of this number. -- cgit v1.2.3