Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jan 2010 05:28:38 GMT
From:      Nick Bowler <nbowler@draconx.ca>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   amd64/143358: nearbyint raises spurious inexact exception
Message-ID:  <201001300528.o0U5Scte025755@www.freebsd.org>
Resent-Message-ID: <201001300530.o0U5U1WI039994@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



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