# Fractions Unit
ReadMe

## Description

The `DelphiDabbler.Lib.Fractions.pas` unit provides a single "Advanced;" record, TFraction that encapsulates a fraction and a number of operations on it.

A whole bunch of operator overloads make it straightforward to perform all the usual arithmetic operations on a fraction and to cast a TFraction to a from an integer or floating point value.

For full details of methods and operator overloads see the comprehensive online documentation. There is no help file.

DUnit tests for TFraction are included in the download.

## Compatibility

This unit requires Delphi 2009 as a minimum and has been tested on all 32 bit Windows compilers from Delphi 2009 to Delphi XE4 and 64 bit Windows compilers from Delphi XE2 to XE4.

## Installation

The Fractions Unit, documentation and test suite are supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:

- `DelphiDabbler.Lib.Fractions.pas` – Main source code.
- `ReadMe.htm` – The unit's read-me file.
- `MPL-2.txt` – Mozilla Public License v2.0.
- `ChangeLog.txt` – The project's change log.
- `Documentation.URL` – Short-cut to the online documentation.

In addition to the above files you will find the DUnit tests in the `Test` sub-directory.

There are three possible ways to use the unit.

1. The simplest way is to add `DelphiDabbler.Lib.Fractions.pas` to your projects as you need it.
2. To make the unit easier to re-use you can either copy it to a folder on your Delphi search path, or add the folder containing the unit to the Delphi Search path. You then simply use the unit as required without needing to add it to your project.
3. For maximum portability you can add the unit to a Delphi package. If you need help doing this see here.

## Update History

A complete change log is provided in the file `ChangeLog.txt`.

## License

The Fractions Unit (`DelphiDabbler.Lib.Fractions.pas`) is released under the terms of the Mozilla Public License v2.0.

All relevant trademarks are acknowledged.

## Acknowledgements

- The information on fractions in the Mathematics Help Facility at http://www.themathleague.com/ was useful in writing this code.
- The GCD and LCM routines were taken from a UseNet post by Hans van Kruijssen.
- The DecimalToFraction routine was adapted from the Turbo Pascal code presented in "Algorithm To Convert A Decimal To A Fraction" by John Kennedy, Mathematics Department, Santa Monica College.

## Bugs and Feature Requests

Bugs can be reported or new features requested via the Issue Tracker.

If no similar report or request has been recorded already, use the New Issue link to add a new issue. Please select the most appropriate template from the Templates drop down list and change the `Project-unspecified` label to `Project-fractions`.

## About the Author

I'm Peter Johnson – a hobbyist programmer living in Ceredigion in West Wales, UK, writing write mainly in Delphi. My programs and code are available from: http://www.delphidabbler.com/.

I can be contacted via the website.

Please do let me know if you have any comments about the unit, but please use the Issue Tracker above to report bugs and request new features.
This document is copyright © 2013-2014, P D Johnson, delphidabbler.com.