Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2019 21:55:03 -0800
From:      Jeff Walden <jwalden@mit.edu>
To:        sgk@troutmask.apl.washington.edu, Dimitry Andric <dim@freebsd.org>
Cc:        freebsd-numerics@freebsd.org
Subject:   Re: UB in various hypot() implementations (left-shifting a negative,  number)
Message-ID:  <11f139aa-708a-4799-dfee-1a5b988a3c0b@mit.edu>
In-Reply-To: <20191116211419.GA40056@troutmask.apl.washington.edu>
References:  <a3fe6fb4-8f33-6d10-64d4-e722bfebcc85@FreeBSD.org> <20191116211419.GA40056@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/16/19 1:14 PM, Steve Kargl wrote:
> Well, clearly, the patch to e_hypotl.c is wrong.  It
> clear the significand when t1 = 0 whereas t1 = 1 leaves
> one bit set in the significand.  Simply looking at the
> value of t1 under a poor man's debugger shows the 
> difference.  Adding "printf("%Le %La\n", t1, t1);" after
> the SET_HIGH_WORD gives
> 
> 2.962347e-2493 0x1p-8280  <-- t1 = 1
> 0.000000e+00 0x1p-8280    <-- t1 = 0
> 
> for hypotl(ldexpl(1.1,-16000), ldexpl(2.1, -16000)).

Hrm.  My understanding based on an earlier line in e_hypotl.c was that that change should be identical, but something mildly subtle is going on and my understanding of |long double| is not quite as good as I thought it was.  I've removed that file's changes and left just the original two in, then resubmitted the diff.

Jeff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?11f139aa-708a-4799-dfee-1a5b988a3c0b>