machine


machine, a FORTRAN90 code which returns machine constants, particularly those related to arithmetic with single precision real and double precision real quantities.

Equivalent FORTRAN90 code functions

In FORTRAN90, there are built-in arithmetic functions that can immediately return the values that MACHINE is supposed to have stored. You should prefer to use the values supplied by FORTRAN90, since these will automatically be adjusted to the appropriate values for the computer you are using, and the arithmetic precision you have chosen!

If X is a single precision real value,then:

If X is a double precision real value, then:

The code must be reset for your computer

MACHINE is not an "intelligent" program; it's simply a way to store and retrieve the information necessary to describe the arithmetic performed on a given computer. Therefore, if you plan to use MACHINE on a particular kind of computer, you must verify that the values being returned are appropriate.

One way to do this is to run the program MACHAR which is an "intelligent" program that actually tries to determine machine arithmetic properties dynamically.

Arithmetic assumptions

MACHINE uses some simple conventions to describe how integers and real numbers are stored on an arbitrary computer.

MACHINE assumes that integers are represented using S digits in base A:

Sign * ( X(S-1)*A^(S-1) + ... + X(1)*A + X(0))

MACHINE assumes that real numbers are represented using a mantissa T, base B and exponent E as:

Sign * T * BE

What MACHINE can return

D1MACH returns quantities associated with double precision arithmetic, including:

  1. B^(EMIN-1), the smallest positive magnitude.
  2. B^EMAX*(1-B^(-T)), the largest magnitude.
  3. B^(-T), the smallest relative spacing.
  4. B^(1-T), the largest relative spacing.
  5. log10(B)

I1MACH returns quantities associated with integer arithmetic, as well as some integer quantities associated with real and double precision arithmetic, and other machine-specific information.

  1. the standard input unit.
  2. the standard output unit.
  3. the standard punch unit.
  4. the standard error message unit.
  5. the number of bits per integer storage unit.
  6. the number of characters per integer storage unit.
  7. A, the base for integers.
  8. S, the number of base A digits in an integer.
  9. A^S-1, the largest integer.
  10. B, the base for single and double precision numbers.
  11. T, the number of base B digits for single precision.
  12. EMIN, the smallest exponent E for single precision.
  13. EMAX, the largest exponent E for single precision.
  14. T, the number of base B digits for double precision.
  15. EMIN, the smallest exponent E for double precision.
  16. EMAX, the largest exponent E for double precision.

R1MACH returns quantities associated with single precision arithmetic, including:

  1. B^(EMIN-1), the smallest positive magnitude.
  2. B^EMAX*(1-B^(-T)), the largest magnitude.
  3. B^(-T), the smallest relative spacing.
  4. B^(1-T), the largest relative spacing.
  5. log10(B)

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

machine is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version and an R version.

Related Data and Programs:

f90_test, FORTRAN90 codes which tests the routines, EPSILON, HUGE, and TINY for evaluating some machine arithmetic quantities directly.

MACHAR, a FORTRAN90 code which can compute machine arithmetic quantities dynamically.

machine_test

NMS, a FORTRAN90 code which includes MACHINE.

Reference:

  1. Phyllis Fox, Andrew Hall, Norman Schryer,
    Algorithm 528: Framework for a Portable Library,
    ACM Transactions on Mathematical Software,
    Volume 4, Number 2, June 1978, page 176-188.
  2. https://www.netlib.org/toms/528
    the NETLIB web site for ACM TOMS algorithms.

Source Code:


Last revised on 29 July 2020.