large_real_kind_1.f90 & huge()

Steve Ellcey sje@cup.hp.com
Thu Sep 8 18:10:00 GMT 2005


I was wondering what the standard is for what value the huge() intrinsic
should return.  The Fortran test gfortran.dg/large_real_kind_1.f90 is
failing on HPPA HP-UX because huge() is returning " +Infinity" and the
test seems to be expecting a large (non-infinite) number.

This works in IA64 Linux & HP-UX because on those systems huge() returns
"0.1189731495E+04933" and things work OK.  On HPPA HP-UX I get +Infinity.

Is it OK for huge() to return +Infinity?

Where is this intrinsic handled?  I couldn't find the source for it.

Steve Ellcey
sje@cup.hp.com



Test case cut down from large_real_kind_1.f90:

program test
  implicit none
  integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)

  real(kind=k) :: x
  character(len=20) :: c1, c2

  x = huge(x)
  write (c1,'(G20.10E5)') x
  write (c2,'(G20.10E5)') -x

  print *, c1
  print *, c2
end program test

On HPPA HP-UX:

            +Infinity
            -Infinity

On IA64 HP-UX:

  0.1189731495E+04933
 -0.1189731495E+04933

On IA64 Linux:

  0.1189731495E+04933
 -0.1189731495E+04933



More information about the Fortran mailing list