
Following the view of C and C++ Working groups at Redmond that a working implementation of my proposal for math functions was a necessary condition for consideration for a TR-2 standard, I have been skirmishing with the problems of converting Stephen Moshier's Cephes code into something that works for both C++ and C. Several issues have emerged, mainly revealing my ignorance with C - a state of bliss in which I would have preferred to remain ;-) 1 Should I no longer cater for non-compliant compilers (usually old-style function specifications? I only have MSVC 8.0 available. 2 How do I check that my code is Standard C compatible (as well as C++)? 3 How do I tell whether the compiler is a C compiler or a C++ compiler (for #if ing). #if __cplusplus #if _STDC__ ... ? 4 I have compiled a module #including <cmath> OK with explicit project property "compile with C++", but when I change this to "compile with C" and no extensions so the /Za option is on the command line, it does not define __STDC__ == 1 as I have expected. What am I doing wrong. 5 Do I have to use exclusively C /* */ style comments :-((? (Or can I assume that C compilers will understand // comments?) I have also immediately come up against the problems of IEEE 754 compliance, argument checks, NaN, infs and exception throwing. 6 Should I assume IEEE 754 compliance and signal #error "Only works with IEEE compliant compilers"? How do I check with C - numeric_limits :: is_IEC559 equivalent? Or would it be foolish to rule out the some older DEC machines? 7 Do you recommend making NaN and inf checks optional? 8 How do I find if they are available, automatically but portably? 9 Can I assume isnan(float, double and long double) with C and with C++? 10 How do I detect isinf? Do I use FPclass for detecting isinf? (pos and neg?) 11 Do you recommend making throwing exceptions optional with C++? 12 Should I scrap all the hexadecimal (mainly polynomial) constants on the grounds that conforming compilers should read decimal digit strings 'correctly' - getting the nearest representable value. Is this true for both C and C++? 13 Do you also recommend making checking arguments optional (with #ifdefs)? So that those who want the ultimate in speed at any risk can switch checking off? Comments welcome. Paul PS Slightly updated versions of my TR2 proposal are at http://www.hetp.u-net.com/public/math_stats_functions_tr2_v2.doc http://www.hetp.u-net.com/public/math_stats_functions_tr2_v2.pdf Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539 561830 +44 7714 330204 mailto: pbristow@hetp.u-net.com