Silverfrost Forums

Welcome to our forums

HUGE for default REAL

4 Mar 2008 12:03 #2881

According to the FTN95 help documentation, the value of HUGE for the default single precision REAL is 3.4028235E+38. Yet when I try to do

REAL aReal
aReal = 3.4028235E+38

the compiler says,

ERROR Floating point number out of range.

However, aReal = HUGE(aReal) seems to compile ok.

Also, I note that DATA maxRl / HUGE(maxRl) / appears to compile ok when it is in a BLOCK DATA subroutine. Shouldn’t the compiler flag this as illegal use of executable code within the block data.

Keith

6 Mar 2008 9:16 #2889

The compiler parses the constant as a REAL10 and then tests it against HUGE(x). So what you observe is the effect of round-off error. That is 3.4028235E+38 (as a REAL10) is greater than HUGE(x).

If you want to use an explicit constant then you must write 3.4028235E+38_2 or its equivalent.

In the DATA statement, HUGE(maxR1) is presumably converted to a constant by the compiler. In other words it does not represent executable code.

If you want FTN95 to be strictly standard conforming then you need to use /ISO on the command line. In this case /ISO does not flag a fault.

Since the DATA statement is old Fortran and HUGE is a new intrinsic, I would be surprised if the Standard had anything to say about this.

Please login to reply.