0**0 
Author Message
 0**0

I'll try posting this again, not quite sure WHERE it went the first
time...

A program I recently recieved generated an invalid exponentiation
error.  Since the program was known to work with the same datq on
another system, I started looking for runtime differences.  After
some testing I discovered that this error always occurred, but was
detected on some systems and ignored on others.  Because the
expression evaluated to 0.0*0.0**0.0 the exact results of the
operation were irrelevant (in this case).  A small test program and
results from several systems follow.  I would be curious to see
results from other systems.  According to page 6-15 of the F77 std
this exception should be detected by a conforming translater.

      program tstexp

c test 0**0 exponentiation

      real*8 x,y,z

      x = 0.0d0
      y = 0.0d0

      call expsub(x,y,z)

      write(*,*) x,y,z

      stop
      end

      subroutine expsub(x,y,z)

      real*8 x,y,z

      z = x**y

      return
      end

machine/OS/compiler     0^0
-----------------       ------
HP750/HPUX/F77          1.0
PC/OS2/Watcom           error
PC/MSDOS/F77L           error
VAX/VMS/fortran 6.2     error
NDP Fortran             ?       runs original program
---
---
 t MR/2 PM 0.99d NR t Radioactive halibut will make fission chips.



Mon, 02 Dec 1996 03:47:00 GMT  
 0**0

Quote:

>                                              ... Because the
> expression evaluated to 0.0*0.0**0.0 the exact results of the
> operation were irrelevant (in this case).  A small test program and
> results from several systems follow.  I would be curious to see
> results from other systems.  According to page 6-15 of the F77 std
> this exception should be detected by a conforming translater.

There is no requirement in the F77 (or F90) standard for a processor to
detect such an exception.  As for almost all requirements in the
standard, the statement on page 6-15 applies to the program and not to
the processor -- see the first paragraph of section 1.4 (page 1-2).

In any case, there are those who believe this operation _is_
"mathematically defined" (at least in certain forms of mathematics).

--

Stanford Linear Accelerator Center, MS 97 | reflect those of SLAC,
P.O. Box 4349; Stanford, CA  94309        | Stanford or the DOE



Tue, 03 Dec 1996 10:00:43 GMT  
 0**0

...
questions about the result of
    0.0**0.0
as in:
        real*8 x,y,z
        x = 0.0d0
        y = 0.0d0
        call expsub(x,y,z)
        write(*,*) x,y,z
        end
        subroutine expsub(x,y,z)
        real*8 x,y,z
        z = x**y
        return
        end

The Convex C-series Fortran compiler prints a runtime warning and sets
z = the largest representable real*8 value.

According to my Analytic Geometry and Calculus text, the exponential
function is undefined for 0^0.  I am not a Fortran standard expert
by any means, and don't have a copy of page 6-15 of the F77 std.
My understanding of past discussions in this forum is that the Fortran
processor is allowed to do whatever it choses for undefined operations.

- Patrick McGehearty



Wed, 04 Dec 1996 04:11:04 GMT  
 0**0

Quote:
> machine/OS/compiler        0^0
> -----------------  ------
> HP750/HPUX/F77             1.0
> PC/OS2/Watcom              error
> PC/MSDOS/F77L              error
> VAX/VMS/Fortran 6.2        error
> NDP Fortran                ?       runs original program

  i486/SVR4/f2c-gcc    1.0   << NEW RESULT

Cheers,
        Glenn
--
___________________________________________________________________________
Glenn Geers                       | "So when it's over,
                                  |  we're back to people.
Department of Theoretical Physics |  Just to prove that human touch
The University of Sydney          |  can have no equal."
Sydney NSW 2006 Australia         |  - Basia Trzetrzelewska, 'Prime Time TV'
                                  |
Phone: +61 2 692-3241 (voice)     |_________________________________________
       +61 2 660-2903 (fax)       |
                                  |

                                  |
----------------------------------------------------------------------------



Thu, 12 Dec 1996 16:45:38 GMT  
 
 [ 4 post ] 

 Relevant Pages 
 

 
Powered by phpBB® Forum Software