[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion of annex D



Guilliume,

Guillaume Melquiond wrote:
Le mardi 29 mai 2007 à 00:08 +1000, Peter Henderson a écrit :
Disagreeing with the C standard, or any other standard for that matter is the correct choice when they specify bad choices. The result will be that users will have the choice of the more considered ieee 754 function or an inferior version.
.
.
.

On one side, we have a _normative_ annex in an _ISO_ standard, that has
been around for ten years, and that has a big influence on several
widely-used programming languages.
I assume you refer to the C99 standard. Similarly, I have only seen a draft version of the ISO/IEC LIA-2 standard, which specifies the desired behaviour of the elementary transcendental functions. As far as I can see (it is after all a very densely packed document), this standard does not specify a C99 style pow(x,y). Instead, it specifies a powerI(float, int) function and a powerF(float, float) function. Crucially, powerF(float, float) returns NaN for the first argument < 0.
On the other side, we have a _non-normative_ annex in a yet to be
released _non-ISO_ standard, that may suggest to change the behavior of
a few corner cases of a not so obscure function described in the
aforementioned ISO standard.
But its predecessor was an IEC standard.  That must count for something. :)
Remark: my point only applies to changing the behavior of an already
standardized function. If the 754r was to define three new functions
(e.g. explog, nth_pow, and nth_root) and if there was no mention of the
pow function, then I am sure the new functions would make their way into
programming language standards.
This is very much my view.  Do not mention pow(x,y).  LIA-2 doesn't.

There is a certain amount of subjectivity in all these decisions. While the purpose of the floating point standard is to bring uniformity to the field of floating point computation, it should also make programmers lives easier and so occasionally there is a strong move to define behaviour that is at odds with the general principles of the standard. In the context of this discussion, the case that comes to mind is pow(0.0, 1.0) = 1.0. The principles of the standard insist pow(0.0, 1.0) return NaN, but for various reasons the former behaviour is preferred by many. Note, for 0.0^1, 1 an integer, 0.0^1 = 1 IS the correct behaviour. However, the objections to having pow(x,y) fulfill the functions of x^y for y both real and integer are much stronger, to the point that the decision is no longer subjective, but objective. Against the many objections to combining the integer and real exponentiation in one function, I can only think of one argument in support of it: it's better to specify one less function, albeit the specification becomes more complicated.

Regards,
Peter Henderson

754 | revision | FAQ | references | list archive