Fraction Library
A C++ Fraction library.

Fraction Library Documentation

Version 1.1

Release Date: March 25, 2011


Download the Fraction Library: ZIP, RAR
Visit the Projects Page

About

The Fraction Library allows you to work with fractions (both improper and mixed) the same way integersare handled in C++. Perform arithmetic, comparision operations, I/O and others.

The Author

My name is Rafat Rashid. You can find more information about me at my website: http://individual.utoronto.ca/rafatrashid.

Installation

Installation is simple. Download the library and then unzip all the files into anywhere in your computer. However, do not change the directory hierachy already set up.

The library was compiled using Microsoft Visual C++ 2010. If you using some other IDE, such as Eclipse, Borland, XCode or even Linux and its Terminal, you may have to do some minor tweaking. For instance, create your own projects, include the appropriate source files and compile it. It is nothing an intermediate programmer can't handle.

In short, if you have a C++ compiler and have some experience in C/C++, you should be able to compile the library, regardless of the environment. If you are having trouble, shoot me an email.

Since I worked with all the IDEs and platforms mentioned above, I may include a step-by-step guide explaining what to do in each senerio at a later date.

Linking the Library to Your Project/Code

Skip this section if you will link the source files into your code base using a method of your own choosing.

The .lib (static library) files are located in the /lib directory. There are two versions, the one in "Debug" subdirectory and the other in "Release". Debug sets macros such as _DEBUG and other details that aid in debugging and testing your code. The Release version is the optimized version. Link one of these libraries into your own project to be able to use the Fraction Library. See the example projects in the /tests directory if you are unsure how to do this (see project properties).

Contents

contents.png

Motivation

The idea of creating a class to handle and manipulate fractions began in grade 12 in high school. I have found I learn by doing and besides, I enjoy programming. So on the summer of 2009, I thought I would pick up where I left off (I had to actually start from scratch as I no longer had the code I had written previously). Landing a job at UofT was also part of the motivation.

Version 1.0 and the predecessor of V.1.1 was released on June 28, 2009.

You can thank Johan Halmen (who contacted me a few months ago with some improvments I can make) for V.1.1.

In developing the Fraction Library, I utilized and built on a lot of tools I learned during my second year in university, including the use of Doxygen to document my code.

Bug Report

If you find any bugs in the library, please notify me by e-mail at enemyunited@gmail.com. Thanks. I am also active on facebook.

General comments and any suggestions on improvements I can make is also appreciated.

Acknowledgements

Thanks goes out to:

  • Dimitri van Heesch for Doxygen. Very impressive and versitile documentation tool.
  • Problem Solving with C++ 6th Edition (a textbook) written by Walter Savitch.
  • Cprogramming.com for being a quick reference for me.
  • Job at UofT which motivated me to learn how to make dynamic and static libraries.

Special thanks goes out to Johan Halmen for suggesting the Fraction::getGCD() algorithm. It's much better than what I had earlier.

Change List

Version 1.1

  • Fraction::getGCD() method features Johan Halmen's algorithm for determining the Greatest Common Divisor of two numbers.
  • Fraction::sign is now a boolean instead of type char.
  • Fraction::setNum() now updates the numerator of the fraction properly.
  • Updated documentation for a better experience.

Version 1.0

Released June 28, 2010

  • Original Fraction Library.