This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv1.1 1/2] Consolidate condition check for return value in mp asin and acos
- From: Andreas Jaeger <aj at suse dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org, Allan McRae <allan at archlinux dot org>
- Date: Mon, 28 Oct 2013 11:02:46 +0100
- Subject: Re: [PATCHv1.1 1/2] Consolidate condition check for return value in mp asin and acos
- Authentication-results: sourceware.org; auth=none
- References: <20131025123854 dot GM23099 at spoyarek dot pnq dot redhat dot com> <526A680D dot 20405 at archlinux dot org> <CAAHN_R25QQYcNtakKNQd-svpitNvCKbddQoTDB8F1Ak8M_NKPg at mail dot gmail dot com> <20131028064730 dot GC1633 at spoyarek dot pnq dot redhat dot com> <526E1A1E dot 5040300 at suse dot com> <20131028094742 dot GA32088 at spoyarek dot pnq dot redhat dot com>
On 10/28/2013 10:47 AM, Siddhesh Poyarekar wrote:
> On Mon, Oct 28, 2013 at 09:02:38AM +0100, Andreas Jaeger wrote:
>> This part should give:
>> a.d[0] > 0 && !(res < res1)
>>
>>> - else
>>> - return (res > res1) ? res : res1;
>>
>> And this condition:
>> !(a.d[0] > 0) && !(res > res1)
>>
>>> + if ((a.d[0] > 0 && res > res1) || (a.d[0] <= 0 && res < res1))
>>
>> In that case it should be res >= res1 for the first paren and "res <=
>> res1" for the second.
>>
>
> Thanks, here's the updated patch. Looks OK now?
Looks fine for me now,
Andreas
> Siddhesh
>
> * sysdeps/ieee754/dbl-64/sincos32.c (__sin32): Consolidate
> conditional check for return value.
> (__cos32): Likewise.
>
>
> diff --git a/sysdeps/ieee754/dbl-64/sincos32.c b/sysdeps/ieee754/dbl-64/sincos32.c
> index f253b8c..49aa148 100644
> --- a/sysdeps/ieee754/dbl-64/sincos32.c
> +++ b/sysdeps/ieee754/dbl-64/sincos32.c
> @@ -147,10 +147,9 @@ __sin32 (double x, double res, double res1)
> __dbl_mp (x, &c, p); /* c = x */
> __sub (&b, &c, &a, p);
> /* if a > 0 return min (res, res1), otherwise return max (res, res1). */
> - if (a.d[0] > 0)
> - return (res < res1) ? res : res1;
> - else
> - return (res > res1) ? res : res1;
> + if ((a.d[0] > 0 && res >= res1) || (a.d[0] <= 0 && res <= res1))
> + res = res1;
> + return res;
> }
>
> /* Receive double x and two double results of cos(x) and return result which is
> @@ -181,10 +180,9 @@ __cos32 (double x, double res, double res1)
> __dbl_mp (x, &c, p); /* c = x */
> __sub (&b, &c, &a, p);
> /* if a > 0 return max (res, res1), otherwise return min (res, res1). */
> - if (a.d[0] > 0)
> - return (res > res1) ? res : res1;
> - else
> - return (res < res1) ? res : res1;
> + if ((a.d[0] > 0 && res <= res1) || (a.d[0] <= 0 && res >= res1))
> + res = res1;
> + return res;
> }
>
> /* Compute sin() of double-length number (X + DX) as Multi Precision number and
>
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126