Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jan 2012 21:26:47 -0500
From:      David Schultz <das@freebsd.org>
To:        Ian Lepore <freebsd@damnhippie.dyndns.org>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: fenv.h fixes for softfloat
Message-ID:  <20120116022647.GA36657@zim.MIT.EDU>
In-Reply-To: <1326591214.1678.85.camel@revolution.hippie.lan>
References:  <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> <1326568038.1678.43.camel@revolution.hippie.lan> <20120114211039.GA18310@zim.MIT.EDU> <1326591214.1678.85.camel@revolution.hippie.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jan 14, 2012, Ian Lepore wrote:
> With the original value 1.1 instead of 1.0, rint() itself raises
> FE_INVALID, in the path that falls out the bottom.  I added printfs:
> 
>         printf("rint 7a: except %#x\n", fetestexcept(FE_ALL_EXCEPT));
>         INSERT_WORDS(x,i0,i1);
>         printf("rint 7b: except %#x\n", fetestexcept(FE_ALL_EXCEPT));
>         STRICT_ASSIGN(double,w,TWO52[sx]+x);
>         printf("rint 7c: except %#x\n", fetestexcept(FE_ALL_EXCEPT));
>         result = w-TWO52[sx];
>         printf("rint 8: except %#x i0=%#x i1=%#x x=%g w=%g result=%g\n", fetestexcept(FE_ALL_EXCEPT), i0, i1, x, w, result);
>         return result;
> 
> And a run using rint(1.1) gave this output:
> 
>         rint 7a: except 0
>         rint 7b: except 0
>         rint 7c: except 0x10
>         rint 8: except 0x10 i0=0x3ff20000 i1=0x9999999a x=1.125 w=4.5036e+15 result=1

I believe 0x10 is FE_INEXACT on arm, not FE_INVALID.  FE_INEXACT
is correct here, because w+TWO52[sx] is inexact.  That still
doesn't explain the lrint() failures, but it makes them less
mysterious.  For instance, the implementation of the cast from
double to int could raise a bogus inexact exception when the
number is an integer to begin with.  In practice, I think the
emulated casts don't raise the proper exceptions even when they
should.  It might depend on whether it's linking against libgcc's
__fixdfsi() or libc's.

Nice catch with the _fpmath.h bug, by the way.  I'll commit that
fix as well.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120116022647.GA36657>