Description

Rational is a C++ class implementing rational numbers of limited size
with overflow detection. Both numerator and denominator are of type
'int'.

Rational allows you to perform exact calculations and verify at any
time if overflow has occurred. Rational does not throw exceptions.

In case of domain error or overflow, denominator is set to 0 and
numerator is set to >0, <0 or 0, meaning +INF, -INF and NAN
respectively. This error condition can be tested with the 'error'
function, and can only be cleared assigning a new value to the Rational.

While in error state, arithmetic operators become no ops and relational
operators return false, except !=, which returns true. This is done so
to preserve the error condition which triggered the error, and because
the error value is considered to be out of domain and therefore is
different from any valid value, but not necessarily larger or smaller.

The 'parse' function is intended as a mean of obtaining values exactly
representable by small fractions from the command line, for example
'0.1', '1/3' or '355/113'.

The 'to_decimal' function prints values in decimal point form (123.456),
while the 'to_fraction' function prints values in fraction form
(123/456). Both functions print "+INF", "-INF" and "NAN" to signal a
error condition.

Values are kept normalized (gcd(numerator,denominator) == 1, and the
denominator is positive).
Range extends from INT_MAX to -INT_MAX.
Maximum resolution is 1 / INT_MAX.

To use the Rational class in your own programs simply copy the files
'rational.h' and 'rational.cc' in your source tree. See also the file
'main.cc' for an example of use.


Copyright (C) 2012-2015 Antonio Diaz Diaz.

This file is free documentation: you have unlimited permission to copy,
distribute and modify it.

The file Makefile.in is a data file used by configure to produce the
Makefile. It has the same copyright owner and permissions that configure
itself.
