On Mon, Jun 2, 2014 at 5:33 AM, Mark Kettenis <[email protected]> wrote:
>> Date: Mon, 2 Jun 2014 10:17:53 +0200 (CEST)
>> From: Mark Kettenis <[email protected]>
>>
>> > Date: Mon, 02 Jun 2014 09:34:20 +0200
>> > From: Benjamin Baier <[email protected]>
>> >
>> > You might want to read up on floating point arithmetic. (rounding and
>> > representation)
>>
>> Well, the difference between 4.994404 and 5.0 is a bit large to blame
>> rounding and binary representation.  And other OpenBSD platforms
>> (amd64, sparc64, powerpc) return the expected result.  So I'd say that
>> there is a bug in the i386-specific implementation of exp2(3).
>
> And here is a fix.  There actually isn't any i386-specific code, but
> i386 is "special" and needs STRICT_ALIGN() to work properly for double
> as well as float.  FreeBSD made the same change a while ago:


Fixes my test case and the numpy test. So ok daniel@ for what it's worth...

>
> http://svnweb.FreeBSD.org/base/head/lib/msun/src/math_private.h?revision=240827&view=markup
>
> Haven't run the regression tests yet with this change.
>
>
> Index: src/math_private.h
> ===================================================================
> RCS file: /cvs/src/lib/libm/src/math_private.h,v
> retrieving revision 1.16
> diff -u -p -r1.16 math_private.h
> --- src/math_private.h  12 Nov 2013 20:35:09 -0000      1.16
> +++ src/math_private.h  2 Jun 2014 09:30:13 -0000
> @@ -349,7 +349,7 @@ do {                                                      
>           \
>  #define        STRICT_ASSIGN(type, lval, rval) do {    \
>         volatile type __lval;                   \
>                                                 \
> -       if (sizeof(type) >= sizeof(double))     \
> +       if (sizeof(type) >= sizeof(long double))        \
>                 (lval) = (rval);                \
>         else {                                  \
>                 __lval = (rval);                \

Reply via email to