Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Largest and smallest real numbers Fortran is capable of handling

770 views
Skip to first unread message

eric948470

unread,
Apr 2, 2010, 4:35:33 PM4/2/10
to
How do I find the largest and smallest real numbers my Fortran77
compiler (gcc) is capable of handling. For example, in C, I'd check
(if I remember correct) REAL_MAX and REAL_MIN in the header file
limits.h. How do I do this in Fortran77?

Richard Maine

unread,
Apr 2, 2010, 4:50:16 PM4/2/10
to
eric948470 <eric9...@gmail.com> wrote:

You look in the compiler documentation (which might not give the answer
in quite that form, but ought to at least give sufficient data to
compute it).

If you insist on the Fortran of 3 decades ago (f77), there really is no
other answer.

F90+ has the HUGE intrinsic, which is at least close. Strictly speaking,
HUGE does not necessarily tell you exactly the value of the largest real
that the compiler can handle, but it ought to be at least a good
approximation to it. In many cases, a good approximation is adequate.
For those wondering about the details, HUGE gives the largest model
number, which might not be exactly the same as the largest representable
number.

For the smallest (by which I assume you mean the smallest in magnitude),
see the TINY intrinsic. In that case, the distinction between model
numbers and representable ones can be more significant if the system
allows denormalized numbers, as those typically are smaller in magnitude
than the model numbers can go.)

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain

mecej4

unread,
Apr 3, 2010, 8:59:21 PM4/3/10
to

Using the values in <limits.h> amounts to relying on those values being
correct for the hardware. I could copy (or inherit, with some downloaded
package), for example, a version of limits.h to a PC with values that
were correct on some other machine, such as a VAX.

If you truly want to _determine_ the values by probing your hardware and
put the results into a header or include file, use the nifty routine

ftp://ftp.netlib.org/blas/machar.f

written by W.J. Cody.

As Richard Maine has already written, this is all unnecessary in Fortran
9X and later.

HTH.

-- mecej4

aerogeek

unread,
Apr 4, 2010, 11:48:09 PM4/4/10
to

If you are using Sun FORTRAN 77, then ephuge might ebthe function you
are looking for. You can check more on this at this link
http://www.oit.uci.edu/dcslib/sun/compilers/fortran/f77rm/6_intrinsics.doc.html

0 new messages