From: Roland Schilling <[log in to unmask]>
Date: Friday, 25 November 2005 2:28
> Program TEST_HUGE
>!
> integer, parameter :: kpr4=selected_real_kind(6) ! 4-byte reals
> real(kpr4) :: r4
>!
> r4 = huge(1.)
> if (r4 < huge(1.)) write(*,*) 'less'
> if (r4 == huge(1.)) write(*,*) 'equal'
> if (r4 > huge(1.)) write(*,*) 'greater'
> end
>The somewhat surprising result is that 'r4' appears greater then
>'huge(1.)' for many compilers, as can be seen when running the
>above program. I tried 7 different compilers: GNU g95, Sun (8.1),
>NAG f95 (4.2), Intel 8.1 and 9.0, IBM xlf90, Lahey-Fujitsu (6.2d).
>Only GNU g95 and Sun gave a warning, all others gave no warning.
>The result was 'greater' for all tested compilers, except for the
>Lahey-Fujitsu which resulted in 'equal'.
>What do the experts think about this problem?
Have you tried printing the values of r4 and huge (1.) ?
>Thanks in advance for any enlightening comments.
>Roland
|