|
IDL Analyst Reference Guide: Math and Statistics Utilities |
|
The IMSL_MACHINE function returns information describing the computer's arithmetic.
| Note This routine requires an IDL Analyst license. For more information, contact your ITT Visual Information Solutions sales or technical support representative. |
Result = IMSL_MACHINE( [, /DOUBLE] [, /FLOAT] )
The information describing the computer's arithmetic is returned in a structure.
If present and nonzero, a structure containing the information describing the single-precision, floating-point arithmetic is returned.
If present and nonzero, a structure containing the information describing the single-precision, floating-point arithmetic is returned.
The IMSL_MACHINE function returns information describing the computer's arithmetic. This can be used to make programs machine independent. The information returned by IMSL_MACHINE is in the form of a structure. A different structure is used for each type: integer, float, and double. Depending on how IMSL_MACHINE is called, a different structure is returned.
The default action of IMSL_MACHINE is to return the structure IMACHINE which contains integer information on the computer's arithmetic. By using either the keywords Float or Double, information about the floating- or double-precision arithmetic is returned in structures FMACHINE or DMACHINE.
The contents of the these structures are described below.
Assume that integers are represented in M-digit, base A form as:

where s is the sign and 0 £ xk < A for k = 0, ..., M. Then, Table 25-4 describes the tags:
Assume that floating-point numbers are in N-digit, base B form as:

where s is the sign and 0 £ xk < B for k = 1, ..., N for and Emin £ E £ Emax. Then, Table 25-5 describes the tags:
Information concerning the floating- or double-precision arithmetic of the computer is contained in the structures FMACHINE and DMACHINE. These structures are returned into named variables by calling IMSL_MACHINE with the keywords Float for FMACHINE and Double for DMACHINE.
Assume that float numbers are represented in Nf- digit, base B form as:

where s is the sign, 0 £ xk < B for k = 1, 2, ..., Nf and
Note that if we make the assignment imach = IMSL_MACHINE( ), then B = imach.FLOAT_BASE, Nf = imach.FLOAT_DIGITS,
and:
The ANSI/IEEE 754-1985 standard for binary arithmetic uses NaN (Not a Number) as the result of various otherwise illegal operations, such as computing 0/0. If the assignment amach = IMSL_MACHINE(/Float) is made, then on computers that do not support NaN, a value larger than amach. MAX_POS is returned in amach.NAN. On computers that do not have a special representation for infinity, amach.POS_INF contains the same value as amach.MAX_POS.
The structure IMACHINE is defined by Table 25-6:
The structure DMACHINE contains machine constants that define the computer's double arithmetic. Note that for double, if the assignment imach = IMSL_MACHINE( ) is made, then:
B = imach.FLOAT_BASE, Nf = imach.DOUBLE_DIGITS
and:
Missing values in IDL Analyst procedures and functions are often indicated by NaN. There is no missing-value indicator for integers. Users usually have to convert from their missing value indicators to NaN.
In this example, all values returned by IMSL_MACHINE are printed on a machine with IEEE (Institute for Electrical and Electronics Engineering) arithmetic.
i = IMSL_MACHINE() f = IMSL_MACHINE(/FLOAT) d = IMSL_MACHINE(/DOUBLE) ; Call HELP with the keyword STRUCTURE set to view the contents ; of the structures. HELP, i, f, d, /STRUCTURE ** Structure IMACHINE, 13 tags, length=52: BITS_PER_CHAR LONG 8 INTEGER_BASE LONG 2 INTEGER_DIGITS LONG 15 MAX_INTEGER LONG 32767 LONG_DIGITS LONG 31 MAX_LONG LONG 2147483647 FLOAT_BASE LONG 2 FLOAT_DIGITS LONG 24 FLOAT_MIN_EXP LONG -125 FLOAT_MAX_EXP LONG 128 DOUBLE_DIGITS LONG 53 DOUBLE_MIN_EXP LONG -1021 DOUBLE_MAX_EXP LONG 1024 ** Structure FMACHINE, 8 tags, length=32: MIN_POS FLOAT 1.17549e-38 MAX_POS FLOAT 3.40282e+38 MIN_REL_SPACE FLOAT 5.96046e-08 MAX_REL_SPACE FLOAT 1.19209e-07 LOG_10 FLOAT 0.301030 NAN FLOAT NaN POS_INF FLOAT Inf NEG_INF FLOAT -Inf ** Structure DMACHINE, 8 tags, length=64: MIN_POS DOUBLE 2.2250739e-308 MAX_POS DOUBLE 1.7976931e+308 MIN_REL_SPACE DOUBLE 1.1102230e-16 MAX_REL_SPACE DOUBLE 2.2204460e-16 LOG_10 DOUBLE 0.30102998 NAN DOUBLE NaN POS_INF DOUBLE Infinity NEG_INF DOUBLE -Infinity
IDL Online Help (March 06, 2007)