openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Weir <>
Subject Re: Solving this 0⁰ issue correctly (was Re: Calc behavior: result of 0 ^ 0)
Date Wed, 20 Feb 2013 18:13:36 GMT
On Wed, Feb 20, 2013 at 12:27 PM, Dennis E. Hamilton
<> wrote:
> I don't want to get into this.  I think enough has been said.
> I do want to avoid anyone misunderstanding what the ANSI/ISO Standards for C and C++
say about pow(0,0) however.
> In general, C/C++ pow(0,0) is left implementation-defined.  There may be a domain error
(this is an implementation-defined result plus setting of a global condition).  There may
be a silent return of NaN.

A domain error is something that an implementation might express via
call to matherr() and setting errno to EDOM is a different question
than the return value.   I'm reading a requirement for pow(x,0) to
return 1 for all values of x.  Are you seeing something else?  Are you
seeing anything that says a conforming C/C++ runtime may *return*
something other than 1?

Btw, the rationale for this choice is described on page 182 of this document:

And I don't think cpow() is relevant to the topic.



>  - Dennis
> In ISO/IEC 14882-1998 (C++) the numeric_limits account for specializations in arithmetic
that provide for +infinity and silent (non-exception-triggering) NaN among other cases.  The
value for *complex* pow(0,0) is implementation-defined in 26.2.8.  For <cmath> (section
26.5) the definitions are deferred to the C Standard <math.h>, although more type specializations
are provided for numtype pow(numtype1, numtype2).
> In ISO/IEC 14882-2003 (C++) is the same.  I haven't checked -2011 and the standardization
of some of the Boost library.
> In ISO/IEC 9899:2011 (C) the specification of cpow( ) does not say anything about cpow(0,0).
 The specification of pow(x,y) says that a domain error may occur if x is zero and y is zero.
 The same language appears in ISO C99 (including its Technical Corrigenda).  In ANSI/ISO C
(way back, before 1992) the rule was that "A domain error occurs if the result cannot be represented
when x is zero and y is less than or equal to zero."  (A domain error involves return of an
implementation-defined value and the global error variable is set - exceptions aren't used
in Standard C libraries.)  So, considerable variability is provided. Quiet NaN and +Inf are
representations, of course, if available in the library and arithmetic implementation.  These
are accounted for in 9899:2011.
>  Plauger's "Standard C Library" (in 1992) assumes IEEE floating point and handles NaN
and +Inf (and his implementation appears to return 1 for pow(0,0) -- the code is pretty snarly).
> -----Original Message-----
> From: Rob Weir []
> Sent: Wednesday, February 20, 2013 07:08
> To:
> Subject: Re: Solving this 0⁰ issue correctly (was Re: Calc behavior: result of 0 ^
> [ ... ] ANSI C, C99, ISO C++ all require that
> pow(x,0) return 1 for all values of x.
> [ ... ]

View raw message