Use of C99 extra long double math functions after r236148
Steve Kargl
sgk at troutmask.apl.washington.edu
Sun Aug 12 23:08:37 UTC 2012
On Thu, Jul 19, 2012 at 08:42:22AM +1000, Peter Jeremy wrote:
> On 2012-Jul-18 10:07:41 -0500, Stephen Montgomery-Smith <stephen at missouri.edu> wrote:
> >I went on a long road trip yesterday, so I didn't get any code written,
> >but I did have a lot of thoughts about clog and casinh.
>
> Can I suggest you have a read through "Implementing the Complex
> Arcsine and Arccosine Functions Using Exception Handling" by
> T. E. Hull Thomas F. Fairgrieve and Ping Tak Peter Tang, ACM
> Transactions on Mathematical Software, Vol. 23, No. 3, September 1997.
> Based on a quick skim, it includes fairly detailed pseudocode,
> together with an error analysis.
It's always good to searh the literature.
>
> On 2012-Jul-18 16:09:06 -0500, Stephen Montgomery-Smith <stephen at missouri.edu> wrote:
> >Am I to understand that the inexact flag should be set anytime a
> >floating point operation produces an answer that is not guaranteed
> >exact?
>
> My understanding is, yes. For the transcendental functions, that
> means the inexact flag should almost always be raised and the problem
> becomes when not to raise it. Eg sin(0) == 0 and presumably doesn't
> set the inexact flag.
>
> > For example, should 1.0/3.0 and sqrt(2.0) raise the inexact flag?
>
> Yes and yes. I notice our sqrtl() actually tests the inexact flag of
> an intermediate calculation to determine the correct rounding for the
> result.
sqrt() is special in that IEEE 754 requires that it return a
correctly rounded result in all rounding modes. See src/e_asin.c
where one cause an inexact to occur. You'll find code fragments
like
if(ix<0x3e500000) { /* if |x| < 2**-26 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
}
huge+x causes the inexact flag to be raised and the condition is
always true.
> I've also found that Abramowitz and Stegun "Handbook of Mathematical
> Functions", 10th printing, is available online at
> http://people.maths.ox.ac.uk/~macdonald/aands/index.html
> and various mirrors. I'm still looking for a copy of Cody & Waite.
NIST recently revised A&S. You can get to online at
http://dlmf.nist.gov/
--
Steve
More information about the freebsd-numerics
mailing list