From: Greg C. <chi...@mi...> - 2002-11-09 17:04:38
|
Danny Smith wrote: > > I'll take out the sqrt inlines (or at least protect with __FAST_MATH__) > from math.h because of the errno problem you report and because of > overriding of builtins when the inlines are there. > > Ditto with fabs Why fabs()? The concern is whether a function can experience a domain or range error. C99 7.12.7.1 doesn't say fabs can, so it doesn't require it to set errno. I don't have C89, but it would be astonishing if it said anything different. The mathematical definition of the function includes positive and negative infinities. The hardware handles subnormals correctly. The only hardware exception FABS can generate is Invalid, with a NaN operand, in which case the NaN just propagates. While C99 is silent on how fabs() handles NaNs, it specifies that copysign() returns a NaN if its first argument is a NaN. So I think 'asm FABS' is already a conforming implementation of fabs(): the hardware is IEEE754 or whatever, and the language doesn't require anything special like setting 'errno'. |