From patchwork Tue Mar 5 16:12:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1908338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=lORB6PhL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tq0w34VxRz23cw for ; Wed, 6 Mar 2024 03:12:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E32738582A2 for ; Tue, 5 Mar 2024 16:12:49 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by sourceware.org (Postfix) with ESMTPS id 52E503858D20 for ; Tue, 5 Mar 2024 16:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52E503858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 52E503858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:4641:c500::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655151; cv=none; b=WB5EmW/GmK43M/rwAWmv3IrF2dnSHnYa9/bQ6VieYa2ID04R2TMr8Mgb6kndqPgxeE+zX7t5ZLeN/K3JU+M1P0zOadCmaMgeNUnTGl9GqOjyw3LjTqwWtNQPBBLEWasDdCPh3P4WH9ryA0B4d9yFLH0hS+9a4n8GHRo6ZEitd5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655151; c=relaxed/simple; bh=b+uVXXGTd0pX50bv0oUryTypE6iK6uDrIrL2PVmuW0Y=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=jQQ16aqMMhMAdvOlrV/7ef2XSdiJzPfCERQA9nkWGG8fMdAK4hdNKy+y4HpsZ+dLku9HWV08rPB/XRNIFLecz+4TPhbawlHN9PPL6E96IDkEzniuViLS8ifiAroWiZQAFifuXnlwLuGqNAc6F0vOt0MJSlSpbSZAmuc2FHe5ric= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EA10461361; Tue, 5 Mar 2024 16:12:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FD38C433F1; Tue, 5 Mar 2024 16:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709655149; bh=b+uVXXGTd0pX50bv0oUryTypE6iK6uDrIrL2PVmuW0Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lORB6PhLUodV9WNh8j2fgpOTH3+ydYzMzlsK2VWN4mne7QCAmZ6MgkR8dQveIXaqS PadjsboHtb5xmeObbJa9CWw8QwmJC/6NLpDfy7b79zLw+CEKlmBv82sWDuZCWwvth0 +HL79ZXzFyeovV+HC66ynuJAaYQREDjSqrdyFjsvArnKd36nLTkINIthdcL8+jEZPt CCgJkXK9PqpZv2Uaz01s4Vv2TsF5UhzkyUuYlxe1Opdqja/09WuT4pQrYmkEEdoC/S XKBaAR3T3I3zWBfh+GIl05nvi5OhXE85RWoSxJDt9hAwGcqP7PEqTM6fSOyekZZJTs qH91Sd03UzTZw== Date: Tue, 5 Mar 2024 17:12:26 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Morten Welinder , Vincent Lefevre , Adhemerval Zanella Netto Subject: [PATCH v2 2/3] manual: floor(log2(fabs(x))) has rounding errors Message-ID: <20240305161213.14364-3-alx@kernel.org> X-Mailer: git-send-email 2.43.0 References: <20240305161213.14364-1-alx@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240305161213.14364-1-alx@kernel.org> X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Link: Reported-by: Vincent Lefevre Suggested-by: Vincent Lefevre Cc: Morten Welinder Cc: Adhemerval Zanella Netto Signed-off-by: Alejandro Colomar --- manual/math.texi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/manual/math.texi b/manual/math.texi index c54eaebb65..79bf3a1401 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -560,8 +560,11 @@ These functions return the base-2 logarithm of @var{x}. @standardsx{logbfNx, TS 18661-3:2015, math.h} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} These functions extract the exponent of @var{x} and return it as a -floating-point value. If @code{FLT_RADIX} is two, @code{logb} is equal -to @code{floor (log2 (fabs (x)))}, except it's probably faster. +floating-point value. +If @code{FLT_RADIX} is two, +@code{logb (x)} is similar to @code{floor (log2 (fabs (x)))}, +except that the latter may give an incorrect integer +due to intermediate rounding. If @var{x} is de-normalized, @code{logb} returns the exponent @var{x} would have if it were normalized. If @var{x} is infinity (positive or