Thread: Numerical System Transformations - Lecture

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    7

    Numerical System Transformations - Lecture

    Hy,

    I wrote new article on Numerical Systems and Transformations yesterday evening (on my C Lessons Project webpage) and would like to share it with you. If someone can help me format my text for this forum, I would appreciate it, so I culd post full article here..

    Here's intro:

    "Our society uses numerical system based on number 10. There is a n0torious explanation why this system is used - it's simple, people have ten fingers, thus makes them easier to calculate numbers. If things were gone different, and something had messed up primordial soup -> developing Homo sapiens with eight fingers, it would be more likely we would use octal numeric system at present time. Infinite number of numerical systems exist, but following are most commonly used, and their conversion from one to another, is simple."

    COntinued:
    http://visualcplus.blogspot.com/2006...ations_08.html

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    I noticed you have 8 link about the subject of bases and conversion. That's really overkill, as there is only 2 types. General purpose, and the fast method for 2^x bases. This subject gets asked quite alot, and it's really easy. Why not add some code?
    Code:
    #include <string>
    #include <ostream>
    #include <iostream>
    using namespace std;
    static char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXZ";
    int main()
    {
    	int input = 150; // choose a number, any number
    	int base = 8; // choose a base <= 32
    	string output;
    	while (input != 0)
    	{
    		output.insert(output.begin(), table[input % base]);
    		input/=base;
    	}
    	cout << output << endl;
    }

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    7
    thnx cool! gonna implement it, just I have to cover some topics about parts of your code first, then I'll introduce this code.

    cya!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Operating System
    By Houssen in forum C Programming
    Replies: 18
    Last Post: 04-22-2008, 12:51 PM
  2. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  3. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  4. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM