Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

IA32 and x64 machine precision?

Ralph_Nelson
Novice
643 Views
I need to input the machine precision information for numerical routines I'm compiling using Win32. I'm running an i7-2600K which I assume follows the standards set forward in the document on http://download.intel.com/design/processor/manuals/253665.pdf pages 4-5 through page 4-9.

If someone could ensure I've input correct values, it would help greatly.

From an initial reoutine
C Words:
C I1MACH( 5) = the number of bits per integer storage unit.
DATA IMACH( 5) / 32 /
C I1MACH( 6) = the number of characters per integer storage unit.
DATA IMACH( 6) / 4 /
C Integers:
C I1MACH( 7) = A, the base.
DATA IMACH( 7) / 2 /
C I1MACH( 8) = S, the number of base-A bits.
DATA IMACH( 8) / 15 /
C I1MACH( 9) = A**S - 1, the largest magnitude.
DATA IMACH( 9) / 32767 /

C Floating Point:
C I1MACH(10) = B, the base.
DATA IMACH(10) / 2 /
C Single-Precision Floating Point:
C I1MACH(11) = T, the number of base-B bits.
DATA IMACH(11) / 31 /
C I1MACH(12) = EMIN, the smallest exponent E.
DATA IMACH(12) / -126 /
C I1MACH(13) = EMAX, the largest exponent E.
DATA IMACH(13) / 127 /
C Double-Precision Floating Point:
C I1MACH(14) = T, the number of base-B bits.
DATA IMACH(14) / 63 /
C I1MACH(15) = EMIN, the smallest exponent E.
DATA IMACH(15) / -1022 /
C I1MACH(16) = EMAX, the largest exponent E.
DATA IMACH(16) / 1023 /
C

No problem with the compilation of this rountine


From a routine associated with single-precision floating point operations
C R1MACH(1) = B**(EMIN-1), the smallest positive magnitude.
C EQUIVALENCE (RMACH(1),SMALL(1))
C INTEGER SMALL(2)
DATA SMALL(1) / 1.18E-38 /
C R1MACH(2) = B**EMAX*(1 - B**(-T)), the largest magnitude.
C EQUIVALENCE (RMACH(2),LARGE(1))
C INTEGER LARGE(2)
DATA LARGE(1) / 1.70E+38 /
C

This rountine has the following error durint compilation:
"r1mach.f(121): error #6906: The value of the integer is either too great or too small, and overflow/underflow occurred. [1.70E+38]"
so it isn't happy with value of "large(1)" I given to it.


Thanks for any help you can provide.
0 Kudos
2 Replies
TimP
Honored Contributor III
643 Views
I recall that someone may have written these widely used subroutines in Fortran 90.
How about
SMALL(1) = TINY(1.)
LARGE(1)=HUGE(1.)
I suppose these intrinsics should work in DATA statements since f2003.
The values EMIN, EMAX need to be increased by 1 for IEEE floating point format IIRC. Take a look at www.ee.ucla.edu/~vandenbe/103/lectures/flpt.pdf


0 Kudos
Steven_L_Intel1
Employee
643 Views
The problem with these routines that try to determine precision is that they can fall afoul of compiler optimizations, precision extensions and more. Fortran 90 defines a large number of intrinsic functions for these values which are properly hard-coded in the compiler. Please use these intead of the routines.
0 Kudos
Reply