Subject: lib/4147: rintf() (3) returns incorrect values
To: None <gnats-bugs@gnats.netbsd.org>
From: Per Amund Amundsen <pa@bsd-amundsen.hsr.no>
List: netbsd-bugs
Date: 09/24/1997 13:22:17
>Number:         4147
>Category:       lib
>Synopsis:       rintf() (3) returns incorrect values
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 24 04:35:00 1997
>Last-Modified:
>Originator:     Per Amund Amundsen
>Organization:
Per Amund Amundsen                           per-am@hsr.no
School of Science and Technology
Stavanger College, PO Box 2557 Ullandhaug    Tlf: (+47) 51 83 18 77
N-4004 Stavanger, Norway		     Fax: (+47) 51 83 17 50
>Release:        1.2.1
>Environment:
	 
	System: NetBSD bsd-amundsen.hsr.no 1.2.1 NetBSD 1.2.1 (BSD-AMUNDSEN)
	#7: Thu Sep 18 14:16:28 MET DST 1997
	pa@bsd-amundsen.hsr.no:/usr/src/sys/arch/i386/compile/BSD-AMUNDSEN
	i386
	libm

>Description:
	The rintf() (3) math library function (float version of
	rint()) returns a nearby multiple of 0.125, although not
	necessarily the closest.

	Really an optimizer bug - quite possibly restricted to i386.

>How-To-Repeat:
	Compile and link the following prograam, and watch it print
	"1.125000"

	#include <stdio.h>
	#include <math.h>
	int main() {printf("%f\n",rintf(1.05));  return 0;}

>Fix:
	Work-around: Compile ../src/lib/libm/src/s_rintf.c 
	from the -current distribution *without optimization*, and link
	with it.
>Audit-Trail:
>Unformatted: