MACHAR
Dynamic Computation of Machine Constants


MACHAR is a FORTRAN90 library which computes constants that characterize the floating point arithmetic system on a computer.

The constants include the value of the "machine epsilon", the smallest number that can be added to 1 and make a difference. However, it includes many other quantities of interest, including the arithmetic base, the largest and smallest magnitudes, and so on.

The FORTRAN77 version of these routines was supplied as part of ACM TOMS algorithm 665.

A C version of these routines was supplied as part of ACM TOMS algorithm 722.

Note that "Numerical Recipes" includes a listing and discussion of MACHAR.

Equivalent FORTRAN90 library functions

In FORTRAN90, there are built-in arithmetic functions that can immediately return the values that MACHAR is trying to determine.

If I is an integer value,then:

If X is a single precision real value, or a double precision real value, then:

Related Data and Programs:

F90 is a directory which includes FORTRAN90 routines for demonstrating features of the FORTRAN90 language, in particular, EPSILON, HUGE, and TINY which evaluate some machine arithmetic quantities directly.

MACHAR is also available in a C version and a C++ version and a FORTRAN77 version and a MATLAB version.

MACHINE is a FORTRAN90 library which store the appropriate values of machine constants for a given machine.

PARANOIA, a FORTRAN90 program which checks the accuracy of floating point arithmetic on a given computer.

Reference:

  1. William Cody,
    Algorithm 665: MACHAR, a subroutine to dynamically determine machine parameters,
    ACM Transactions on Mathematical Software,
    Volume 14, Number 4, December 1988, pages 303-311.
  2. William Cody, William Waite,
    Software Manual for the Elementary Functions,
    Prentice Hall, 1980,
    ISBN: 0138220646,
    LC: QA331.C635.
  3. Morven Gentleman, Scott Marovich,
    More on Algorithms that Reveal Properties of Floating Point Arithmetic Units,
    Communications of the ACM,
    Volume 17, Number 5, May 1974, pages 276-277.
  4. Michael Malcolm,
    Algorithms to Reveal Properties of Floating Point Arithmetic,
    Communications of the ACM,
    Volume 15, Number 11, November 1972, pages 949-951.
  5. William Press, Brian Flannery, Saul Teukolsky, William Vetterling,
    Numerical Recipes in FORTRAN: The Art of Scientific Computing,
    Second Edition,
    Cambridge University Press, 1992,
    ISBN: 0-521-43064-X,
    LC: QA297.N866.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the FORTRAN90 source codes.


Last revised on 11 November 2006.