diff options
author | Olivier Gayot <og@satcom1.com> | 2017-11-19 13:13:32 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2017-11-26 11:34:33 +0100 |
commit | 07f6748c9ae255227903bde4fe359bc31c943494 (patch) | |
tree | 8b0a1b9be7ddf0bf477f86bb17cd495c624713a7 /number.cpp | |
parent | 70d94b803db40423d23bd01e347b33f3a931ad4f (diff) |
Added the conversion from number to 64 bits integer
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'number.cpp')
-rw-r--r-- | number.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -70,6 +70,26 @@ number::to_uint32() const return (*this == 0) ? 0 : _operands.front(); } +std::uint64_t +number::to_uint64() const +{ + auto size = _operands.size(); + + if (size > 2) { + throw std::out_of_range("> UINT64_MAX"); + } + + std::uint64_t result = 0; + + for (auto it = _operands.crbegin(); it != _operands.crend(); ++it) { + result <<= 32; + + result |= (*it); + } + + return result; +} + number::operator bool() const { return *this != 0; |