aboutsummaryrefslogtreecommitdiff
path: root/bigint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bigint.cpp')
-rw-r--r--bigint.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/bigint.cpp b/bigint.cpp
index 21c4ab2..9fdafe0 100644
--- a/bigint.cpp
+++ b/bigint.cpp
@@ -133,8 +133,9 @@ Bigint& Bigint::operator=(slongdigit_t v){
}
Bigint& Bigint::operator+=(const Bigint &o){
- if(&o==this){
- return *this=Bigint(*this)+=o;
+ if(&o==this){ //*this + *this
+ operator<<=(1);
+ return *this;
}
if(sign==1){
if(o.sign==1)add(*this,o);
@@ -148,8 +149,10 @@ Bigint& Bigint::operator+=(const Bigint &o){
}
Bigint& Bigint::operator-=(const Bigint &o){
- if(&o==this){
- return *this=Bigint(*this)-=o;
+ if(&o==this){ // *this - *this
+ sign=1;
+ digits.clear();
+ return *this;
}
if(sign==1){
if(o.sign==1)subtract(*this,o);