Thread: converting bases

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    converting bases

    how would i convert a number of one base into the same number in a different base for example how would i get a 10 in base of 4 to the 4 it is in a base of 10?
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    What do you mean, "base"?
    1978 Silver Anniversary Corvette

  3. #3
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125
    well, our number system is in a base of ten it only has ten possible digits in a base of four it goes 0,1,2,3,10 using only four digits. i need to know how to convert them
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    So, what are the four digits of the 4 based system?
    1978 Silver Anniversary Corvette

  5. #5
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    _itoa() will convert an integer to a string and allows you to specify the base, or you could do something like -

    int a= 5;
    int base = 4;

    int b = a/base*10 + a%base;
    //b will contain 11 in this case
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 07-25-2008, 04:37 AM
  2. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. Converting denary to other bases
    By rhysmeister in forum C++ Programming
    Replies: 6
    Last Post: 03-14-2004, 08:44 AM
  5. converting string to float
    By twhubs in forum C Programming
    Replies: 1
    Last Post: 09-16-2001, 09:02 AM