delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/30/12:48:03

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 30 Jun 2005 09:47:40 -0700
From: Yitzchak Scott-Thoennes <sthoenna AT efn DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: Bug in printf ?
Message-ID: <20050630164740.GA3104@efn.org>
References: <20050630 DOT 202057 DOT 83613389 DOT haro AT kgt DOT co DOT jp> <20050630 DOT 202554 DOT 129758646 DOT haro AT kgt DOT co DOT jp> <8864897 DOT 1120133151080 DOT JavaMail DOT adm-moff AT moffice2 DOT nsc DOT no> <20050630 DOT 214457 DOT 02636322 DOT haro AT kgt DOT co DOT jp>
Mime-Version: 1.0
In-Reply-To: <20050630.214457.02636322.haro@kgt.co.jp>
User-Agent: Mutt/1.4.2.1i
X-IsSubscribed: yes

On Thu, Jun 30, 2005 at 09:44:57PM +0900, haro AT kgt DOT co DOT jp wrote:
> ::Dealing with integers illustrates the matter more clearly. When
> ::the decimal value is exactly 0.5, then printf should round to the
> ::nearest *even* integer, as far as I know, so you should get
> 
> Hi Peter,
> 
> Thank you for your explanation. I didn't know, until now, that
> rounding should be done to the "nearest *even* integer".
> Need to learn every day. ;-)

This is done to prevent systemic bias.

However, note that
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html says:
"The low-order digit shall be rounded in an implementation-defined manner."
so while people have come to expect unbiased rounding, it isn't actually
mandatory AIUI under vanilla SUSv3.

Also see "What Every Computer Scientist Should Know About
Floating-Point Arithmetic" at (among other places)
http://docs.sun.com/source/806-3568/ncg_goldberg.html.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019