#
*Dan Nagle's Technical Site*

* Module type_rational*

Home
-->
Fact Sheet
-->
Free Source Code
--> type_rational

##
About the Module type_rational

Go directly to Downloads

The module type_rational defines a type rational
containing two 32 bit integers. This module includes arithmetic and logical
operators and extends some intrinsic procedures to operate on objects of type
rational. This module uses module
standard_types, which may be obtained from
the Portability Project pages.

Back to the Top

A list of (most) constants and procedures defined follows.

**Operators**
**=** is extended to allow conversion between a
type rational value and an integer array of size two.
**+** and **-** unary operators
providing identity and negation, and returning values of type rational.
**.inverse.** and **.reduce.**
unary operators providing inverse and reduction to lowest terms.
**+**, **-**, ***** and **/**
are binary operators, returning values of type rational.
**.eq.**, **.ne.**,
**.lt.**, **.le.**, **.ge.** and
**.gt.** are binary operators returning a logical value.

Back to the Top

**Library**
**rat()** converts its integer input to type rational.
**int()** truncates its rational input to integer.
**nint()** converts its rational input to the closest integer.
**real()** converts its rational input to type real.
**sign()** returns an integer with the sign of a rational.
**abs()** returns a rational with positive value.
**huge()**, **tiny()** and
**epsilon()** return the largest rational value, the smallest
rational value or the smallest rational value which may be added to unity to
get a value different from unity.
**numerator()** and
**denominator()** return the numerator or denominator or a type
rational entity.
**is_finite()**, **is_infinity()**
and **is_nan()** return logical values characterizing their
rational arguments.
**inverse()** returns the rational inverse of
its rational argument.
**reduce()** returns a rational value equal to
its rational argument reduced to lowest terms.
**swap()** swaps its rational arguments.
**bit_size()** returns the bit size of its rational argument.

Back to the Top

To download the type_rational module, click
type_rational. This module
depends on the standard_types module, see
the portability project
for information about how to make one for your compiler.

Back to the Top

To make comments or suggestions regarding
standard_functions, or any of our software, please
E-mail me. We're always happy to share
the experiences others have using our software.

Home -
Fact Sheet -
Free Source Code -
Fortran Links -
Email me

Back to the Top