View previous topic :: View next topic |
Author |
Message |
Keith Waters
Joined: 07 Aug 2007 Posts: 29 Location: London or Somerset, UK
|
Posted: Tue Mar 04, 2008 1:03 pm Post subject: HUGE for default REAL |
|
|
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
Code: | REAL aReal
aReal = 3.4028235E+38 |
the compiler says,
ERROR Floating point number out of range.
However, Code: | aReal = HUGE(aReal) | seems to compile ok.
Also, I note that Code: | 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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Thu Mar 06, 2008 10:16 am Post subject: |
|
|
The compiler parses the constant as a REAL*10 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 REAL*10) 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. |
|
Back to top |
|
|
|