From 0b99682299afe4ea8dd2880625b5e636ee859c29 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Wed, 14 Nov 2018 00:11:33 -0500 Subject: [PATCH] Removed the failed BigInt class --- BigInt.hpp | 145 ----------------------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 BigInt.hpp diff --git a/BigInt.hpp b/BigInt.hpp deleted file mode 100644 index e5737ef..0000000 --- a/BigInt.hpp +++ /dev/null @@ -1,145 +0,0 @@ -//myClasses/BigInt.hpp -//Matthew Ellison -// Created: 11-4-18 -//Modified: 11-4-18 -//This class uses a vector of ints to make a larger int - -///THIS CLASS IS CURRENTLY STILL IN TESTING!!! -///It can only handle addint and multiplying possitive numbers right now - - -#include -#include -#include -#include - -namespace mee{ -class BigInt{ -private: - std::vector num; - void overflow(){ - //This function handles any overflows that occured during the operations - //Limit each number to < 1B - for(int cnt = 0;cnt < num.size();++cnt){ - while(num.at(cnt) >= 1000000000){ - if(num.size() > cnt + 1){ - num.at(cnt + 1) += 1; - } - else{ - num.push_back(1); - } - num.at(cnt) -= 1000000000; - } - } - ///How do you handle negatives? - } -public: - BigInt(){ num.push_back(0); } - BigInt(int64_t n) : num(n) { } - BigInt(BigInt& n){ num = n.num; } - //std::vector getNums(){ return num; } - BigInt operator+(const BigInt& rightSide){ - BigInt temp; - while(rightSide.num.size() > temp.num.size()){ - temp.num.push_back(0); - } - while(num.size() > temp.num.size()){ - temp.num.push_back(0); - } - int largerSize; - if(rightSide.num.size() > num.size()){ - largerSize = rightSide.num.size(); - } - else{ - largerSize = num.size(); - } - for(int cnt = 0;cnt < largerSize;++cnt){ - int64_t ls; - int64_t rs; - if(cnt < num.size()){ - ls = num.at(cnt); - } - else{ - ls = 0; - } - if(cnt < rightSide.num.size()){ - rs = rightSide.num.at(cnt); - } - else{ - rs = 0; - } - temp.num.at(cnt) = ls + rs; - } - temp.overflow(); - return temp; - } - BigInt operator+(const int rightSide){ - BigInt temp; - temp.num.at(0) = num.at(0) + rightSide; - temp.overflow(); - return temp; - } - /* These are not ready. need to account for borrowing - BigInt operator-(const BigInt& rightSide){ - BigInt temp; - while(rightSide.num.size() > temp.num.size()){ - temp.num.push_back(0); - } - while(num.size() > temp.num.size()){ - temp.num.push_back(0); - } - for(int cnt = 0;cnt < rightSide.num.size();++cnt){ - int64_t ls; - int64_t rs; - temp.num.at(cnt) = ls - rs; - } - overflow(); - return tempInt; - } - BigInt operator-(const int rightSide){ - num.at(0) -= rightSide; - overflow(); - return tempInt; - } - */ - BigInt operator*(const BigInt& rightSide){ - - } - BigInt operator*(const int rightSide){ - BigInt tempInt = *this; - for(int cnt = 1;cnt < rightSide;++cnt){ - tempInt += *this; - } - tempInt.overflow(); - return tempInt; - } - BigInt& operator=(const BigInt& rightSide){ - num = rightSide.num; - return *this; - } - BigInt& operator=(const int rightSide){ - num.clear(); - num.push_back(rightSide); - return *this; - } - void operator+=(const BigInt& rightSide){ - *this = *this + rightSide; - } - void operator+=(const int rightSide){ - *this = *this + rightSide; - } - void operator*=(const BigInt& rightSide){ - *this = *this * rightSide; - } - void operator*=(const int rightSide){ - *this = *this * rightSide; - } - std::string printNum() const{ - std::string number; - for(int cnt = num.size() - 1;cnt >= 0;--cnt){ - number += std::to_string(num.at(cnt)); - } - return number; - } -}; -}