amd64/143358: nearbyint raises spurious inexact exception
Nick Bowler
nbowler at draconx.ca
Sat Jan 30 05:30:02 UTC 2010
>Number: 143358
>Category: amd64
>Synopsis: nearbyint raises spurious inexact exception
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-amd64
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jan 30 05:30:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Nick Bowler
>Release: 8.9
>Organization:
>Environment:
FreeBSD amythaon.draconx.ca 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009 root at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
The nearbyint function is required by the C standard to *not* raise the
inexact floating point exception, and the FreeBSD man page concurs.
Nevertheless, the exception is raised on FreeBSD 8.0, as demonstrated by
the following program:
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
int main(void)
{
double val;
fenv_t env;
feholdexcept(&env);
printf("inexact: %d\n", fetestexcept(FE_INEXACT) != 0);
val = nearbyint(0x1.6p2);
printf("inexact: %d\n", fetestexcept(FE_INEXACT) != 0);
fesetenv(&env);
printf("%f\n", val);
return 0;
}
>How-To-Repeat:
Compile and run the above program. It prints 0, 1 and 6.00000. It should print 0, 0 and 6.00000.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-amd64
mailing list