From nobody@FreeBSD.org  Wed Feb 27 09:31:06 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id DDF6037B41A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Feb 2002 09:31:05 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g1RHV5d29073;
	Wed, 27 Feb 2002 09:31:05 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200202271731.g1RHV5d29073@freefall.freebsd.org>
Date: Wed, 27 Feb 2002 09:31:05 -0800 (PST)
From: David Monniaux <monniaux@genievre.ens.fr>
To: freebsd-gnats-submit@FreeBSD.org
Subject: incorrect floating-point display of large values when using round-upward IEEE mode
X-Send-Pr-Version: www-1.0

>Number:         35381
>Category:       misc
>Synopsis:       incorrect floating-point display of large values when using round-upward IEEE mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 27 09:40:00 PST 2002
>Closed-Date:    Thu Jul 14 18:55:32 GMT 2005
>Last-Modified:  Thu Jul 14 18:55:32 GMT 2005
>Originator:     David Monniaux
>Release:        4.4
>Organization:
ENS
>Environment:
FreeBSD airelle 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Mon Jan  7 11:46:25 CET 2002     root@airelle:/usr/src/sys/compile/AIRELLE  i386

>Description:
Very large floating-point values (very close to the maximal non
infinite number for the current IEEE precision mode, i.e.
DBL_MAX = 1.7976931348623157E+308 when left to the default)
are displayed incorrectly if the system has been put in
round-upward mode (using fpsetround()).

The output string is not even a valid number (contains a colon
in place of a digit).

>How-To-Repeat:
#include <ieeefp.h>
#include <stdio.h>

main()
{
  fpsetround(FP_RP);
  printf("%g\n", 1E308);
}

airelle% ./essai 
:e+307

^^ incorrect display
>Fix:
Save/restore the floating-point rounding mode
(and possibly precision mode) around library functions that expect
a particular mode.
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: David Monniaux <monniaux@genievre.ens.fr>
Cc: <freebsd-gnats-submit@FreeBSD.ORG>
Subject: Re: misc/35381: incorrect floating-point display of large values
 when using round-upward IEEE mode
Date: Thu, 28 Feb 2002 23:30:06 +1100 (EST)

 On Wed, 27 Feb 2002, David Monniaux wrote:
 
 > >Description:
 > Very large floating-point values (very close to the maximal non
 > infinite number for the current IEEE precision mode, i.e.
 > DBL_MAX = 1.7976931348623157E+308 when left to the default)
 > are displayed incorrectly if the system has been put in
 > round-upward mode (using fpsetround()).
 >
 > The output string is not even a valid number (contains a colon
 > in place of a digit).
 
 This will have to be fixed to support C99, but the general problem
 is large and won't be fixed soon.  C99 seems to require the following
 (if support for its equivalent fesetround() is actually claimed):
 - functions like printf(), scanf() and strtod(), and lower-level
   ones related to rounding must honour the current rounding mode.
   I don't know how hard this is.
 - other lower-level functions must not depend on the rounding mode.
   This basically requires pessimizing all the functions by context-
   switching to the default rounding mode while executing them.
 
 Using fpsetprec() and fpsetmask() to change the defaults causes similar
 problems, but there are no corresponding interfaces in C99, and it's
 not clear how non-default precisions should affect standard functions.
 
 Bruce
 
Responsible-Changed-From-To: freebsd-bugs->freebsd-standards 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Sep 1 03:24:22 GMT 2004 
Responsible-Changed-Why:  
This sounds like a standards issue (from reading the followup). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35381 
State-Changed-From-To: open->closed 
State-Changed-By: das 
State-Changed-When: Thu Jul 14 18:54:48 GMT 2005 
State-Changed-Why:  
Fixing this in 4.X would require substantial changes. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35381 
>Unformatted:
