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 function 'error', and can only be cleared
by 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 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 function 'parse' can be used to obtain values exactly representable by
small fractions like '0.1', '1/3', or '355/113' from the command line.

The function 'to_decimal' prints values in decimal point form (123.456),
while the function 'to_fraction' prints values in fraction form (123/456).
Both functions print '+INF', '-INF', or 'NAN' to signal an 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 class Rational in your own programs simply copy the files
'rational.h' and 'rational.cc' in your source tree. See the file 'main.cc'
for an example of use.


Copyright (C) 2012-2022 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.
