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

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Apr 27 22:10:12 AEST 2001


On 27-Apr-2001, Pablo Lopez <lopez at lcc.uma.es> wrote:
> 
> 
> Terrence Brannon wrote:
> > 
> > in the last clause of this function, is is used instead of =. Why is
> > this? In fact, what is is?
> > 
> > float__pow(X, Exp) = Ans :-
> >         ( Exp < 0 ->
> >                 error("float__pow taken with exponent < 0\n")
> >         ; Exp = 1 ->
> >                 Ans =  X
> >         ; Exp = 0 ->
> >                 Ans = 1.0
> >         ;
> >                 New_e is Exp - 1,
> >                 Ans is X * float__pow(X, New_e)
> >         ).
> 
> I'm a newbie to Mercury, but I think
> that according to the definition above
> 
>   float_plow(0,0) = 1

Actually `float__pow(0.0, 0) = 1.0', but yes.

> however, this should be undefined....
> or am I missing the point???

Opinions on whether `pow(0, 0)' should be defined differ.  I think most
mathematicians would define it pow in such a way that pow(0, 0) is undefined.
However, some extend the definition so that pow(0, 0) = 1.  This, I've been
told, works nicely with certain equations (such as the Binomial something-or-
other -- sorry, I don't recall the details), because it avoids the need for
special-casing.

Because of this, I think the LIA (Language Independent Arithmetic)
standard and/or the IEEE floating point standard defines pow(0, 0) = 1.
However, I'm not sure of it.  I'll check the LIA standards next week,
when I'm in my office.

Personally, I think it would be better to leave pow(0, 0) undefined.
However, I also think that on these kinds of minor issues, if there is an
existing standard, then it is usually better for Mercury to conform to the
appropriate standard rather than to strike out on our own course.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  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