From twp@ma-1.rootsweb.com Mon Mar 29 14:19:27 1999
Return-Path: <twp@ma-1.rootsweb.com>
Received: from ma-1.rootsweb.com (ma-1.rootsweb.com [209.192.148.153])
	by hub.freebsd.org (Postfix) with ESMTP id 9F32714C27
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Mar 1999 14:19:17 -0800 (PST)
	(envelope-from twp@ma-1.rootsweb.com)
Received: (from twp@localhost)
	by ma-1.rootsweb.com (8.9.3/8.9.3) id RAA11713;
	Mon, 29 Mar 1999 17:09:54 -0500 (EST)
Message-Id: <199903292209.RAA11713@ma-1.rootsweb.com>
Date: Mon, 29 Mar 1999 17:09:54 -0500 (EST)
From: twp@rootsweb.com
Sender: twp@ma-1.rootsweb.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: rint(3) returns erratic results
X-Send-Pr-Version: 3.2

>Number:         10863
>Category:       bin
>Synopsis:       rint(3) returns erratic results
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 29 14:20:01 PST 1999
>Closed-Date:    Sun Apr 4 14:13:43 PDT 1999
>Last-Modified:  Sun Apr  4 14:14:19 PDT 1999
>Originator:     Tim Pierce
>Release:        FreeBSD 2.2.7-RELEASE i386
>Organization:
RootsWeb Genealogical Data Cooperative
>Environment:

	

>Description:

rint(3) appears to return inconsistent results for some inputs.  For
example, it rounds both 5.5 and 6.5 to 6.  If rint always rounds up,
it should round these numbers to 6 and 7; if it always rounds down, it
should round these numbers to 5 and 6; if it always rounds to the
nearest integer, it should round to 6 and 7.  Is there any situation
where it would be correct to round both 5.5 and 6.5 to 6?

>How-To-Repeat:

#include <math.h>

main()
{
    printf ("%f\n", rint(5.5));
    printf ("%f\n", rint(6.5));
}

>Fix:
	
	



>Release-Note:
>Audit-Trail:

From: Bill Fumerola <billf@jade.chc-chimes.com>
To: twp@rootsweb.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/10863: rint(3) returns erratic results
Date: Mon, 29 Mar 1999 17:35:25 -0500 (EST)

 On Mon, 29 Mar 1999 twp@rootsweb.com wrote:
 
 > #include <math.h>
 
 Nothing to do with this PR, but why does math(3) have lots of (3M)
 references in it 'list of functions' section?
 
 If this is the wrong behavior I'll fix it, but I don't know if it is.
 (This would be where you set me straight, Bruce...)
 
 - bill fumerola - billf@chc-chimes.com - BF1560 - computer horizons corp -
 - ph:(800) 252-2421 - bfumerol@computerhorizons.com - billf@FreeBSD.org  -
 
 
 
 

From: Dave Bodenstab <imdave@mcs.net>
To: twp@rootsweb.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/10863: rint(3) returns erratic results
Date: Mon, 29 Mar 1999 23:59:48 -0600

 twp@rootsweb.com wrote:
 > 
 > >Number:         10863
 > >Category:       bin
 > >Synopsis:       rint(3) returns erratic results
 > >Confidential:   yes
 > >Severity:       serious
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Quarter:
 > >Keywords:
 > >Date-Required:
 > >Class:          sw-bug
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Mon Mar 29 14:20:01 PST 1999
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Tim Pierce
 > >Release:        FreeBSD 2.2.7-RELEASE i386
 > >Organization:
 > RootsWeb Genealogical Data Cooperative
 > >Environment:
 > 
 > 
 > 
 > >Description:
 > 
 > rint(3) appears to return inconsistent results for some inputs.  For
 > example, it rounds both 5.5 and 6.5 to 6.  If rint always rounds up,
 > it should round these numbers to 6 and 7; if it always rounds down, it
 > should round these numbers to 5 and 6; if it always rounds to the
 > nearest integer, it should round to 6 and 7.  Is there any situation
 > where it would be correct to round both 5.5 and 6.5 to 6?
 > 
 > >How-To-Repeat:
 > 
 > #include <math.h>
 > 
 > main()
 > {
 >     printf ("%f\n", rint(5.5));
 >     printf ("%f\n", rint(6.5));
 > }
 > 
 > >Fix:
 
 See ieeefp.h and floatingpoint.h: this is the correct behaviour
 for the default rounding mode of `round to nearest'.  See the
 Intel manuals for the exact definition of each rounding mode...
 briefly, round to nearest chooses the even number if the difference
 to the next higher/lower integer is the same.
 
 Change your program to the following and inspect the results.
 
 #include <math.h>
 #include <floatingpoint.h>
 
 main()
 {
   printf( "FP_RN:\n" );
   fpsetround( FP_RN );
   printf ("%f\n", rint(5.5));
   printf ("%f\n", rint(6.5));
 
   printf( "FP_RM:\n" );
   fpsetround( FP_RM );
   printf ("%f\n", rint(5.5));
   printf ("%f\n", rint(6.5));
 
   printf( "FP_RP:\n" );
   fpsetround( FP_RP );
   printf ("%f\n", rint(5.5));
   printf ("%f\n", rint(6.5));
 
   printf( "FP_RZ:\n" );
   fpsetround( FP_RZ );
   printf ("%f\n", rint(5.5));
   printf ("%f\n", rint(6.5));
 }
 
 Dave Bodenstab
 imdave@mcs.net
 

From: Tim Pierce <twp@rootsweb.com>
To: Dave Bodenstab <imdave@mcs.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/10863: rint(3) returns erratic results
Date: Tue, 30 Mar 1999 01:44:57 -0500

 On Mon, Mar 29, 1999 at 11:59:48PM -0600, Dave Bodenstab wrote:
 > 
 > See ieeefp.h and floatingpoint.h: this is the correct behaviour
 > for the default rounding mode of `round to nearest'.  See the
 > Intel manuals for the exact definition of each rounding mode...
 > briefly, round to nearest chooses the even number if the difference
 > to the next higher/lower integer is the same.
 
 Glork.  Thanks, I stand corrected.  Sorry for the bogus report.
 
 -- 
 Regards,
 Tim Pierce
 RootsWeb Genealogical Data Cooperative
 system obfuscator and hack-of-all-trades
 
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sun Apr 4 14:13:43 PDT 1999 
State-Changed-Why:  
Closed at originator's request. 
>Unformatted:
