pow( -INFINITY, 0.5 ) (fwd)

David C. Knaak uunet!juniper.cray.com!knaak
Mon Aug 30 12:07:11 PDT 1993


**************** finish and send *************


Tim Peters
> From uunet!ksr.com!timauunet.UU.NET Sat Aug 28 19:52:13 1993
> To: tydemanaibmpa.awdpa.ibm.com
> Subject: Re: pow( -INFINITY, 0.5 )
> Cc: ncegacray.com
> Date: Sat, 28 Aug 93 17:18:36 -0400
> From: Tim Peters <uunet!ksr.com!timauunet.UU.NET>
> 
> If it bothers you that
> 
>    current_pow(-inf,0.5) = +inf silently
> 
> is not the same as
> 
>    ieee_sqrt(-inf) = qNaN and signal invalid
> 
> it should also bother you that
> 
>    current_pow(-0,0.5) = +0 silently
> 
> is not the same as
> 
>    ieee_sqrt(-0) = -0 silently
> 
> 
> current_pow satisfies the pleasing
> 
>    pow(1/x,0.5) is identical (both result & exceptions) to 1/pow(x,0.5)
> 
> when x is an infinity or zero, while ieee_sqrt(1/x) and 1/ieee_sqrt(x)
> are not always the same (they differ for x in {-inf, -0}).
> 
> The special cases here are really an interlocking rat's nest, and
> consistent changes are hard won.  E.g., you want also to preserve that
> pow(x,y) = pow(1/x,-y) when possible.  So if you change pow(-inf,0.5) to
> be NaN instead of the current +inf, you should also change
> pow(1/-inf,-0.5) = (one hopes!) pow(-0,-0.5) to be NaN instead of the
> current +inf.  But then pow(-0,-0.5) "should be" the same as
> 1/pow(-0,0.5) too, and for the latter to be a NaN you need to define
> pow(-0,0.5) to be a NaN.  Nobody would be happy with pow(-0,0.5) = NaN.
> 
> 
> The point is that it's not possible to meet both of the following
> simultaneously:
> 
> 1) pow endcases satisfy the basic identities relating reciprocals and
>    exponent negation
> 
> 2) pow(x,0.5) handles endcases the same as ieee_sqrt(x)
> 
> The hangup is not in the defn of pow, but that IEEE's sqrt endcases
> don't always meet sqrt(1/x) = 1/sqrt(x).
> 
> and-if-i-ever-see-an-actual-program-that-relies-on-sqrt-of-minus-zero-
>    being-minus-zero-i'll-probably-die-laughing<grin>-ly y'rs  - tim
> 
> Tim Peters   timaksr.com
> not speaking for Kendall Square Research Corp
> 


I would like to paraphrase Tim's final comment to express my view:

   and-if-i-ever-see-an-actual-program-that-relies-on-sqrt-of-minus-zero-
   being-minus-zero-i'll-begin-to-take-serious-interest-in-these-discussions.
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As I have stated before, most recently in document X3J11.1/93-016, I do not 
see enough value in the infinity and minus zero end cases to warrant added 
lots of complexity to the C language.  I have seen only

David Knaak
knaakacray.com




More information about the Numeric-interest mailing list