From owner-freebsd-standards@FreeBSD.ORG Thu Jul 21 18:50:33 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org 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 01C1A16A420 for ; Thu, 21 Jul 2005 18:50:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 775C243D53 for ; Thu, 21 Jul 2005 18:50:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6LIoJK6064860 for ; Thu, 21 Jul 2005 18:50:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6LIoJr1064859; Thu, 21 Jul 2005 18:50:19 GMT (envelope-from gnats) Date: Thu, 21 Jul 2005 18:50:19 GMT Message-Id: <200507211850.j6LIoJr1064859@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Roman Bogorodskiy Cc: Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Roman Bogorodskiy List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2005 18:50:33 -0000 The following reply was made to PR standards/83845; it has been noted by GNATS. From: Roman Bogorodskiy To: David Schultz Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: standards/83845: [ patch ] add log2() and log2f() support for libm Date: Thu, 21 Jul 2005 22:51:31 +0400 David wrote: > Though this seems like a reasonable approach, it leads to > significant rounding errors since it requires dividing an inexact > result (ln(x) rounded to 52 bits) by another inexact quantity > (ln(2) rounded to 52 bits). For instance, I suspect that if you > computed log2(2), log2(4), log2(8), log2(16), ... using your > implementation, the results would not always be exact. > Technically speaking I don't think they are required to be exact, > but common sense suggests that they ought to be. Is not it exact? $> ./a.out=20 log2(2) =3D 1.0000000000000000000000 log2(4) =3D 2.0000000000000000000000 log2(8) =3D 3.0000000000000000000000 log2(16) =3D 4.0000000000000000000000 $>=20 It's exact enough for me. > A more minor objection is that log2() can be computed more quickly > than log(), but this impelementation does it less quickly. This > isn't such a big deal, though; I'm more concerned about the > problem that accuracy guarantees will be significantly weaker than > for other routines in libm. Ok. You know, log2() confirms to C99 and some apps become to use it now. Su= re,=20 it's not problem for me to add hacks like #define log2(x) log(x)/log(2) whi= le=20 you're looking for the ideal solution. Roman Bogorodskiy