[PATCH] hypotl, cabsl, and code removal in cabs

Steve Kargl sgk at troutmask.apl.washington.edu
Thu Dec 6 15:15:44 PST 2007


On Thu, Dec 06, 2007 at 04:08:33AM -0500, David Schultz wrote:
> I like the approach. One concern, though, is that IEEE 754
> requires sqrt to always be correctly rounded, and one might
> reasonably expect the same from hypot. If we believe that, then
> the intermediate quantity a*a + b*b needs to be computed exactly;
> if it is rounded before we take the square root, the double
> rounding may cause us to round the wrong way. This basically
> requires computing things with twice as many bits of precision.
> Arguably, though, your code is correct in the most important
> ways (avoiding underflow/overflow).
> 
> Also, umm, I've been busy and unable to pay attention for a while,
> so forgive me if I'm missing something, but isn't it the case that
> we don't have a sqrtl(), except for the gcc builtin on some
> architectures?

David,

bde pointed me to the right file in src/libm/ieee that explains
the rounding issues with hypotl.  I haven't had a chance to
update my implementation to use extra care in the evaluation of
a*a+b*b.

As to the sqrtl question, I have an implementation that supposely
does correct rounding in all rounding modes.  It is restricted to
64-bit significand long doubles.  The code does not use bit twiddle;
instead, it uses fenv.

-- 
Steve


More information about the freebsd-standards mailing list