aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint/bigint.cpp
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-22 00:15:55 +0200
committerSimon Warta <[email protected]>2015-07-24 10:33:40 +0200
commite5e8635ab5e21991e890b229c9c563ffeec2db31 (patch)
tree3f8e34c177b46ac95706958f9d84dfa8cdcd1783 /src/lib/math/bigint/bigint.cpp
parent10883bb5b8fb2804b9af08c7cfe9f869be811d0b (diff)
Refactor BigInt
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
*/