[mercury-users] Re:[mercury-users] Re: [mercury-users] difference between is and =?

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 4 23:58:32 AEST 2001


On 30-Apr-2001, Richard A. O'Keefe <ok at atlas.otago.ac.nz> wrote:
> Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 
> > Opinions on whether `pow(0, 0)' should be defined differ.
> 
> It would make a huge amount of mathematics pointlessly difficult
> if the axiom
>                  0
>     (for all x) x  = 1
> 
> did not hold.

Not pointlessly; the point is to avoid computing erroneous results
in cases where the other limit (the limit as x->0 of 0^x = 0)
is the one desired.

This issue has been discussed on the C/C++ standards mailing lists
recently.  Nick Maclaren wrote:

 | The cost of returning the wrong value quietly is vastly more than the
 | cost of having to special-case the code.  As has been known for many
 | decades in software engineering (back to the days when it was known
 | as good programming and language design), requiring the programmer
 | to check for every error is disastrously unreliable - the only safe
 | solution is to have such checks inserted automatically.

So, as I said, opinions differ.

However, it turns out that for LIA-2 (the Language Independent Arithmetic
standard, part 2), Richard O'Keefe's view has in the end prevailed, at least
for the pow(float, int) case -- see below.

So I plan to go ahead and document that behaviour in the Mercury standard
library documentation.

 | From: Henry Spencer <henry at spsystems.net>
 | To: C++ C compatibility mailing list
 | 
 | On Tue, 3 Jul 2001, Howard Hinnant wrote:
 | > > ...(For anyone who hasn't run into this:  most languages
 | > > which separate those two cases, and the LIA-2 standard as well, say that
 | > > 0.0^0.0 is exception/NaN/whatever, while 0.0^0 is 1.0 without 
 | > > complaint.)
 | > 
 | > Hmm... Is LIA-2 final?  I have only looked at a working draft version of 
 | > LIA-2 dated November 30, 1995.
 | 
 | That's probably the first draft.  The one that finally went in as the
 | standard (and yes, I believe it has issued) was the fourth, dated Sept 30,
 | 1999.  A lot can happen in four years...
 | 
 | > In this draft there are three "POWER" functions:
 | > POWER_FF (takes two floating arguments)
 | > POWER_FI (takes a float and integral argument)
 | > POWER_II (takes two integral arguments)
 | 
 | Disregarding some details (there are a couple of POWER_FF variants added),
 | the final draft has the same three. 
 | 
 | > In all three versions 0^0 is marked to return "undefined".
 | 
 | The final draft says POWER_FF and POWER_II yield "invalid" (which is a
 | "notification") for 0^0, but POWER_FI yields 1 without notification. 
 | 
 | > The rationale in LIA-2 (wd) says...
 | > > The specification in LIA-2 follows Ada, and returns undefined for 0^0, 
 | > > because of the risks inherent in returning a result which might be 
 | > > incorrect for the application at hand.
 | 
 | The final draft's rationale says the same thing, *but* goes on to note
 | that POWER_FI is different.  It say that the only two *continuous* paths
 | for that function approaching 0^0 both have a limiting value of 1, and
 | that yielding 1 without notification is consistent with the treatment of
 | float^int in Ada and others which distinguish it from float^float. 
 | 
 |                                                           Henry Spencer
 |                                                        henry at spsystems.net

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list