MACHINE
Table of Machine Constants
MACHINE
is a MATLAB library which
returns machine constants, particularly those related to arithmetic
with single precision real and double precision real quantities.
MACHINE 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.
MACHINE's 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(S1)*A^(S1) + ... + X(1)*A + X(0))
MACHINE assumes that real numbers are represented using a
mantissa T, base B and exponent E as:
Sign * T * B^{E}
What MACHINE can return
D1MACH returns quantities associated with double precision
arithmetic, including:

B^(EMIN1), the smallest positive magnitude.

B^EMAX*(1B^(T)), the largest magnitude.

B^(T), the smallest relative spacing.

B^(1T), the largest relative spacing.

log10(B)
I1MACH returns quantities associated with integer arithmetic,
as well as some integer quantities associated with real and
double precision arithmetic, and other machinespecific information.

the standard input unit.

the standard output unit.

the standard punch unit.

the standard error message unit.

the number of bits per integer storage unit.

the number of characters per integer storage unit.

A, the base for integers.

S, the number of base A digits in an integer.

A^S1, the largest integer.

B, the base for single and double precision numbers.

T, the number of base B digits for single precision.

EMIN, the smallest exponent E for single precision.

EMAX, the largest exponent E for single precision.

T, the number of base B digits for double precision.

EMIN, the smallest exponent E for double precision.

EMAX, the largest exponent E for double precision.
R1MACH returns quantities associated with single precision
arithmetic, including:

B^(EMIN1), the smallest positive magnitude.

B^EMAX*(1B^(T)), the largest magnitude.

B^(T), the smallest relative spacing.

B^(1T), the largest relative spacing.

log10(B)
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
MACHINE is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
MACHAR,
a MATLAB library which
computes machine arithmetic quantities dynamically.
Reference:

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 176188.

http://www.netlib.org/toms/528
the NETLIB web site for ACM TOMS algorithms.
Source Code:

d1mach.m,
returns double precision real machine constants.

i1mach.m,
returns integer machine constants.

r1mach.m,
returns single precision real machine constants.

timestamp.m,
prints the current YMDHMS date as a timestamp.
Examples and Tests:
You can go up one level to
the MATLAB source codes.
Last revised on 26 September 2008.