From e5e8635ab5e21991e890b229c9c563ffeec2db31 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 22 Jul 2015 00:15:55 +0200 Subject: Refactor BigInt --- src/lib/math/bigint/bigint.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib/math/bigint/bigint.cpp') diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index 045117cbd..242a7fe0b 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -173,6 +173,11 @@ void BigInt::clear_bit(size_t n) m_reg[which] &= ~mask; } +size_t BigInt::bytes() const + { + return round_up(bits(), 8) / 8; + } + /* * Count how many bits are being used */ @@ -253,6 +258,12 @@ BigInt BigInt::abs() const return x; } +void BigInt::grow_to(size_t n) + { + if(n > size()) + m_reg.resize(round_up(n, 8)); + } + /* * Encode this number into bytes */ -- cgit v1.2.3