Date: Sat, 5 Jun 2004 15:49:16 -0700 From: David Schultz <das@FreeBSD.ORG> To: "Steven G. Kargl" <kargl@troutmask.apl.washington.edu>, FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: standards/59797: Implement C99's round[f]() math fucntions Message-ID: <20040605224915.GA3306@VARK.homeunix.com> In-Reply-To: <20040605025359.GA3084@VARK.homeunix.com> References: <200311291810.hATIAIWu084953@freefall.freebsd.org> <200312101711.hBAHBoEL007529@troutmask.apl.washington.edu> <20040605025359.GA3084@VARK.homeunix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040605224915.GA3306>