Hi Regina, On Monday, 2009-04-06 10:11:43 +0200, Regina Henschel wrote:
> I'm working to increase accuracy of ScArcCosHyp(). The function acosh is > part of C99 but not provided by MSVC. Therefore I have written the > ersatz in sal\rtl\source\math.cxx Nice. > double SAL_CALL rtl_math_acosh( double fX ) SAL_THROW_EXTERN_C() > { > double fZ = fX - 1.0; It might be necessary to declare fZ as volatile here. We already had such a case that the gcc compiler attempted to overoptimize things, see comments in rtl_math_log1p(). > if ( fX == 1.0) > return 0.0; > else if (fX < 1.1) > return rtl_math_log1p(fZ+sqrt(fZ*fZ+2.0*fZ)); > else if ( fX < 1.25e7) > return log(fX+sqrt(fX*fX-1.0)); > else > return log(2.0*fX); > } > > The function acosh is not defined for x<1. The function ScArcCosHyp() > pushes an IllegalArgument and do not call acosh in that cases. > > Do I need any kind of error handling in my rtl_math_acosh? The function > acosh might be called from somewhere else, not only from ScArcCosHyp. Yes, please return a NaN in that case: double fResult; rtl::math::setNan( &fResult ); return fResult; Calc's interpreter will handle a NaN result automatically. Eike -- OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer. SunSign 0x87F8D412 : 2F58 5236 DB02 F335 8304 7D6C 65C9 F9B5 87F8 D412 OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't send personal mail to the e...@sun.com account, which I use for mailing lists only and don't read from outside Sun. Use er...@sun.com Thanks.
pgpTIquIQWL72.pgp
Description: PGP signature