aboutsummaryrefslogtreecommitdiffstats
path: root/src/big_base.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2007-03-03 05:48:54 +0000
committerlloyd <[email protected]>2007-03-03 05:48:54 +0000
commit2e08f75d02c3b08e6d8c983bae963f5709aa8311 (patch)
treec0a28d9f95e305db0a994caa5bb6ad13649903a7 /src/big_base.cpp
parenteb8b4aa9c0fa9e57f3c2446478714d596d873592 (diff)
BigInt::operator[] now guards against accesses that are larger than the
current register size; reads return 0, writes extend the buffer.
Diffstat (limited to 'src/big_base.cpp')
-rw-r--r--src/big_base.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/big_base.cpp b/src/big_base.cpp
index 158d967fb..a6d9e3e9e 100644
--- a/src/big_base.cpp
+++ b/src/big_base.cpp
@@ -338,6 +338,23 @@ BigInt BigInt::operator-() const
}
/*************************************************
+* Return a reference to the indexed word *
+*************************************************/
+word& BigInt::operator[](u32bit index)
+ {
+ reg.grow_to(index+1);
+ return reg[index];
+ }
+
+/*************************************************
+* Return the value of the indexed word *
+*************************************************/
+word BigInt::operator[](u32bit index) const
+ {
+ return (index < size()) ? reg[index] : 0;
+ }
+
+/*************************************************
* Return the absolute value of this number *
*************************************************/
BigInt BigInt::abs() const