Skip over navigation

Fractions Unit

Encapsulates fractions and operations on them

Version 0.1.2-beta
Released 2023-12-13
Platforms Win32 & Win64
Framework RTL
Compatibilty Delphi 2009 & later

Overview

This unit, named DelphiDabbler.Lib.Fractions.pas, provides a single Delphi Pascal "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 and from an integer or floating point value.

Testing

DUnit tests for TFraction are included in the download.

Get The Code

You can download the latest version of the Fractions Unit directly from SourceForge as dd-fractions-0.1.2-beta.zip.

Download v0.1.2-beta

The Fractions Unit source code is hosted in the ddablib/fractions GitHub repository. You can git clone or fork the repository as required.

Installation

The Fractions Unit is 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 – source code.
  • README.md – read-me file.
  • CHANGELOG.md – project change log.
  • MPL-2.txt – the Mozilla Public License v2.0.
  • Documentation.URL – short-cut to the class' online documentation.

In addition to the above files you will find the DUnit tests for DelphiDabbler.Lib.Fractions.pas 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 where you extracted the unit to the 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 design time package. If you need help doing this see here.

Documentation

The Fractions Unit is comprehensively documented online here

Read-me file: README.md

Change log: CHANGELOG.md.

Feedback & Queries

If you find any bugs or want to suggest a new feature please report them using the Fractions Unit issue tracker.

If you have created a bug fix or have implemented a new feature please open a pull request for it.

Should you have any queries about using the unit please read the documentation. If you can't find an answer in the documentation then post a message in the discussion group.

License

The Fractions Unit is open source. It is copyright © 2013-2023 by Peter Johnson. The source code is made available under the terms of the Mozilla Public License v2.0. All relevant trademarks are acknowledged.