My Own Number Base System/Big int?
Hello, Im tring to make up my own number system. I tried tring to make a map, but I think it is more of a table. Im kinda having hard times adding the numbers of my new system together when it gets to them being different lengths. I would like it if people can view my code and tell me what they think? of any improvements I can make and so fourth. If Im doing good with it thus far? And I think I figured out how to make my own big int. Is this how they make big int classes and stuff? Well Thanks Take care
Byebye.
Ps. Not sure if this is the place to post this. If not sorry.
Code:
#include<iostream>
using namespace std;
int nw[10];
short Lookup(char number[],int place){
char map[]={'0','1','2','3','4','5','6','7','8','9'
,'A','B','C','D','E','F','G','H','I','J','K','L','M'
,'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
,'a','b','c','d','e','f','g','h','i','j','k','l','m'
,'n','o','p','q','r','s','t','u','v','w','x','y','z'};
char n[]={'0','0','0','0','0','0','9','A','C','A'};
short value=-1;
short parseM=0;
for(int i=0;i<61;i++){
if(number[place]==map[parseM]){
value=parseM;
return value;
}
else{
++parseM;
}
}
return value;
}
void Add(char n[],char n2[],int sizeN,int sizeN2){
int base=61;
int top;
int indexNW=9;
if(sizeN<sizeN2){
top=sizeN;
}
else{
top=sizeN2;
}
for(top;top>=0;top--,sizeN--,sizeN2--,indexNW--){
nw[indexNW]=Lookup(n,sizeN)+Lookup(n2,sizeN2)+nw[indexNW];
nw[indexNW-1]=nw[indexNW]/base+nw[indexNW-1];
nw[indexNW]=nw[indexNW]%base;
}
}
int main(){
for(int i=0;i<10;i++){
nw[i]=NULL;
}
char map[]={'0','1','2','3','4','5','6','7','8','9'
,'A','B','C','D','E','F','G','H','I','J','K','L','M'
,'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
,'a','b','c','d','e','f','g','h','i','j','k','l','m'
,'n','o','p','q','r','s','t','u','v','w','x','y','z'};
char n[]={'0','0','0','0','0','0','0','0','0','A'};
char n2[]={'0','0','0','0','0','0','0','0','0','5'};
int sizeN=sizeof(n)/sizeof(char)-1;
int sizeN2=sizeof(n2)/sizeof(char)-1;
Add(n,n2,sizeN,sizeN2);
for(int i=0;i<10;i++){
cout<<map[nw[i]];
}
system("PAUSE");
return 0;
}