aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint/bigint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/math/bigint/bigint.cpp')
-rw-r--r--src/lib/math/bigint/bigint.cpp11
1 files changed, 11 insertions, 0 deletions
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
*/