   Really big numbers
  well lol i was a bit bored today so i wrote a program that stores an arbitarily large "number"anyways try it out if you want, i didn't overload any operators, i might for practice. Also it is sloooow, it took almost 30seconds to add 2 billion + 2 billion  lol   #include <iostream>using namespace std;class dint{   public:   friend void dspdint(dint);   friend dint multiDint(dint,dint);   friend dint addDint(dint,dint);   void add(unsigned int a,unsigned int b);   void multi(unsigned int a,unsigned int b);   dint(const dint&);   dint(int);   dint();   ~dint();   void fpushback(int);   unsigned char *n;   private:   int size,pushback;};dint::dint(const dint& d){    size=d.size;pushback=d.pushback;n=new unsigned char[size];for(int i=0; i<size+1; i++) n[i]=d.n[i];    }dint::dint() { size=4; pushback=1; n= new unsigned char[size];}dint::dint(int varsize) {size=varsize; pushback=1; n=new unsigned char[size];for(int i=0; i<size+1; i++) n[i]=0; }dint::~dint(){ delete [] n;}void dint::add(unsigned int a,unsigned int b){   int index=0;   while(a>0)   {if(n[0]<10) {n[0]++; a--;}else while(n[index]==10) {n[(index+1)]++;n[index]=0; index++;}index=0;   }index=0; while(b>0)   {if(n[index]<10) {n[index]++; b--;}else while(n[index]==10) {n[(index+1)]++;n[index]=0; index++;}index=0;  }    }void dint::multi(unsigned int a,unsigned int b){    while(b){ addDint(a,0); b--; }}void dspdint(dint dn){ int index=dn.size; short temp = 0;  int j=index; bool bIndex(true);  for(int i=index; i>=0; i--){    while (!dn.n[j] && bIndex) j--; //cout<<"j="<<j;    if(j>=i) {temp = dn.n[i]; cout<<temp;}    bIndex=false;}}dint addDint(dint a,dint b){  int index=0;  int count(0);  int temp(0);  dint c(10);   while(count<c.size){c.n[count]+=a.n[count]+b.n[count];if (c.n[count]>=10) {c.n[(count+1)]++; c.n[count]-=10;}count++;   }  return c;}    dint multiDint(dint num, dint dintNum){  //dint c =addDint(num,dintNum)} int main(){   dint a(10),b(10); unsigned int a2,a3=0; while(a2!=123){   cin>>a2>>a3;   a.add(a2,0);   b.add(a3,0);   dspdint(a);cout<<"+"; dspdint(b); cout<<" = ";   dint test=addDint(a,b);   dspdint(test);}   system("pause");} [edited by - hades11 on December 18, 2003 7:01:59 PM]