Submitter: Fred J. Tydeman (USA)
Submission Date: 2010-06-17
Subject: Remove ambiguous choices in math functions
Currently, several of the math library functions allow implementations too much choice as how to indicate errors. That is, one implementation may indicate a domain error, while another implementation may indicate a range error for the same function call, e.g., lrint(DBL_MAX). This makes writing portable applications difficult in that there is no one specific error to check for in all cases.
There are two proposals here. They are independent of each other. They should each have their own vote. As written, these two proposals have no impact on current implementations. They are giving guidance and future directions.
On the other hand, if we decide to make these changes normative now, then change proposal 1 "should" to "shall" and remove the "Recommended Practice".
Proposal 1: add recommended practices.
184.108.40.206 The ilogb functions
ilogb(zero) should be a domain error. ilogb(infinity) should be a domain error. ilogb(NaN) should be a domain error.
220.127.116.11 The logb functions
logb(zero) should be a pole error.
18.104.22.168 The pow functions
pow(zero,less than zero) should be a pole error.
22.214.171.124 The tgamma functions
tgamma(zero) should be a pole error. tgamma(negative integer) should be a domain error.
126.96.36.199 The lrint and llrint functions
lrint(too large) should be a domain error. llrint(too large) should be a domain error.
188.8.131.52 The lround and llround functions
lround(too large) should be a domain error. llround(too large) should be a domain error.
Proposal 2: add obsolescent features.
Add a new section to 7.29 Future library directions: 7.29.N Math <math.h:>
The following error conditions are obsolescent features.
Add the following to the Rationale for <math.h>:
Having different implementations indicate different math errors for the same function call makes it difficult for applications to be portable code. An example of this is: pow(0.0,-1.0); where one implementation calls it a domain error, while another implementation calls it a pole error. This ambiguity may be removed in a future revision of the standard.