This code below add two positive numbers in any base from binary to base 36 with any length allowed by memory. The snippet comes with examples. There might be some bugs, because I haven't tested extensively, so forgive me if you find bugs. Hope people find it useful somehow. Thanks for reading. -------------------------------------------------------------------------------------- Oh. Found a bug, after positing this post, of course, For the isValidNum function the if statement inside the for loop should be this : if( unsigned(toBaseInt(num[pos])) >= base ) return false; the comparison needed to be >= instead of >. Sorry for the bug.

Member Avatar
Member Avatar
+0 forum 3

The simplest sort, although inefficient. Below is a demonstration of bubble sort and insertion sort. The bubble sort just consists of 2 for loops and std::swap. The insertion sort uses 2 loops as well but not as much swap as bubble sort. Any questions ?

Member Avatar
Member Avatar
+1 forum 3

Its a typical implementation of mergesort algorithm. It runs in a stable time of O(n*log(n) ). Just thought, I would add it to the library. Its been tested, although not very throughly, so if any bugs are found, just post it here, so others can be aware of them. Its not commented much, if any, because I thought it was self explainable. I realize that it could have been made more flexible, but I just wasn't interested enough. Happy Coding.

Member Avatar
Member Avatar
+0 forum 3

This is a simple demonstration of meta programming. It shows the idea of meta programming. It basically calculates the factorial of a number before runtime. When I first saw the concept of meta programming, it blew my mind so badly. I was so surprised that one could do this. Its soooo kewl, don't you think?

Member Avatar
Member Avatar
+2 forum 2

We are all tired of from our daily lives. So I suggest to sit back and play this game. I present here a hangman game( text version ) for your enjoyment. There might be some bugs as I haven't throughly tested it, so sorry if you find it( I'm sure you can fix it ). Happy late Chinese new year! P.S no cheating, and get your vocabs up...

Member Avatar
Member Avatar
+1 forum 2

Some background. We all used the string class, but some of you might not know that string is just a typedef of basic_string. In fact here is the typedef you might find when looking in the XString library. [code] typedef basic_string<char, char_traits<char>, allocator<char> > string; [/code] This code snippet shows you how to use basic_string to your advantage. It has almost the same functionality as the string library but it adds some functionality. It has [I]little [/I]error checking. Again this is shown as an example to learn from. Here is a list of things to keep in mind : - …

Member Avatar
Member Avatar
+2 forum 5

The function adds two large numeric string together, like "12345667" + "12345678" = ? It does not have complete error checking, I'll leave that up to you. It should work but I am prone to bugs, so do advise if bugs are found. Included are also helper function that helps us add the large numeric string

Member Avatar
Member Avatar
+4 forum 1

It uses the idea of Seive of Eratosthenes. The code is basically does the following to find Prime Numbers : 1) Populate Array from 0 - > MAX 2) Find 1st Prime, which is 2 3) Delete all Multiple of 2, i.e set it to false 4) Find next prime, which is 3 5) Delete all multiple of 3 6) Repeat steps 4 - 6 until done. I also use a little try and catch, just to provide as an example.

Member Avatar
+0 forum 0

Convert string to other datatypes via template. See below.

Member Avatar
+0 forum 0

Random number generator under its own namespace. Its a sample program.

Member Avatar
+0 forum 0

The End.