From owner-freebsd-standards@FreeBSD.ORG Mon Jun 7 01:28:23 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D146016A4D8; Mon, 7 Jun 2004 01:28:23 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id AB8A143D1F; Sun, 6 Jun 2004 18:28:23 -0700 (PDT) (envelope-from kargl@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) i571SNeG068543; Sun, 6 Jun 2004 18:28:23 -0700 (PDT) (envelope-from kargl@troutmask.apl.washington.edu) Received: (from kargl@localhost)i571SNuN068542; Sun, 6 Jun 2004 18:28:23 -0700 (PDT) (envelope-from kargl) From: "Steven G. Kargl" Message-Id: <200406070128.i571SNuN068542@troutmask.apl.washington.edu> In-Reply-To: <20040605224915.GA3306@VARK.homeunix.com> To: David Schultz Date: Sun, 6 Jun 2004 18:28:23 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL99f (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII cc: FreeBSD-gnats-submit@FreeBSD.ORG cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/59797: Implement C99's round[f]() math fucntions X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2004 01:28:24 -0000 David Schultz wrote: > On Fri, Jun 04, 2004, David Schultz wrote: > > Sorry, I've put this off way too long. The good news is that I'm > > now going to do something about it. The bad news is that I found > > a significant bug in the proposed implementation. Namely, round() > > and roundf() often get the wrong answer for halfway cases. In > > IEEE-754 round-to-nearest mode, numbers that are halfway between > > two representable numbers are supposed to be rounded to even. > > It seems I've paged out more material from my brain than I thought > since I last looked at this. POSIX defines round() to > specifically *not* use the IEEE-754 round-to-nearest behavior. > Your implementation is absolutely correct, Steve, and it even gets > the exception flags right. (I tested all positive inputs to > roundf(), probed inputs to round() uniformly at random for a few > minutes, and checked important special cases.) I'll go ahead and > commit it with minor style and doc fixes. > I would have to go back and review the PR for all the discussion, but I thought bde had proposed using rint(3) with an appropriate rounding mode. Anyway, whatever you decide to do is fine with me. BTW, thanks for the work on fenv. Sorry, I couldn't provide a review. I did look at your patch, but it was way over my head. -- Steve http://troutmask.apl.washington.edu/~kargl/