How to deal with repeating rational numbers
Okay, I feel like this is a pretty STUPID question, but the way to do it has just not came to me at all. I wrote a program that converts any number to a selected base, including rational numbers and negatives (unbiased of course). The dilemma I am facing, however, is when I have repeating numbers. for example, when I convert a number to binary and get something like 101.1100110011001100110011001100. I want to fina a conventional way to trim the output so that it only prints unique digits after the decimal point. DO NOT givd me C++ code, but some form of psuedo code or perhaps just a suggestion to point me in the right direction. My first idea was put the numbers in an array, then search the array and compare values until it finds a repeating pattern. This is however a little consuming, and causes alot of bloat in my source. Any sugestions would be apperciated... even if it is a simple predefined function included in C++ that does htis for me.