From owner-freebsd-standards@FreeBSD.ORG Sat Jun 5 15:50:45 2004 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CBD516A4E2 for ; Sat, 5 Jun 2004 15:50:45 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 55CEB43D45 for ; Sat, 5 Jun 2004 15:50:45 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i55MoUKq087072 for ; Sat, 5 Jun 2004 15:50:30 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i55MoU9e087071; Sat, 5 Jun 2004 15:50:30 -0700 (PDT) (envelope-from gnats) Date: Sat, 5 Jun 2004 15:50:30 -0700 (PDT) Message-Id: <200406052250.i55MoU9e087071@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: David Schultz 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 Reply-To: David Schultz List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2004 22:50:45 -0000 The following reply was made to PR standards/59797; it has been noted by GNATS. From: David Schultz To: "Steven G. Kargl" , FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Cc: Subject: Re: standards/59797: Implement C99's round[f]() math fucntions Date: Sat, 5 Jun 2004 15:49:16 -0700 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.