My Own Number Base System/Big int?

This is a discussion on My Own Number Base System/Big int? within the C++ Programming forums, part of the General Programming Boards category; Hello, Im tring to make up my own number system. I tried tring to make a map, but I think ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    49

    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;
    }

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Two quick suggestions are that you could format it nicer, and to remove the system("PAUSE") call. System commands are unportable, slow, and insecure.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by MadCow257
    [...] system("PAUSE") call. System commands are unportable, slow, and insecure.
    Hehehe, I don't think speed is an issue here. Think about what system("pause") actually does.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 06:20 AM
  3. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21