| Title: | Digital Fortran |
| Notice: | Read notes 1.* for important information |
| Moderator: | QUARK::LIONEL |
| Created: | Thu Jun 01 1995 |
| Last Modified: | Fri Jun 06 1997 |
| Last Successful Update: | Fri Jun 06 1997 |
| Number of topics: | 1333 |
| Total number of notes: | 6734 |
Customer has following problem: c c DEC Fortran for WNT version 1.2 tested on both c WNT 4.0 and 3.51 c program power3 implicit double precision (a-z) c following works: r=-2**3 write(*,*)r c following produces: c forrtl: severe: Program Exception - floating invalind operation x=-2. y=3. w=x**y write(*,*)w end I suspect RTL errors ... Help ! =Seva
| T.R | Title | User | Personal Name | Date | Lines |
|---|---|---|---|---|---|
| 1238.1 | use /check=nopower to get C semantics from ** | TLE::WHITLOCK | Stan Whitlock | Tue Mar 25 1997 08:13 | 26 |
there are several things going on here:
>> r=-2.**3.
is evaluated as -(2.**3.) since ** takes precedence over unary - in standard
Fortran rules. So the answer is -8.
>> (-2.)**3.
is illegal Fortran, both by Fortran 77 and Fortran 90. Therefore you get an
error at run-time.
But DFANT v1.2 has the "/check=nopower" switch, which changes the semantics of
** to be like C, ie,
o 0.**0. == 1.
o negative number to an odd integer power works
so if you compile with "/check=nopower" {the deafult is "/check=power"}, you'll
get -8. from (-2.)**3.
"/check=[no]power" is available in f90 and f77 on Alpha/VMS, Alpha/UNIX, and
Alpha/NT {spelled appropriately for the platform}.
/Stan
| |||||