From patchwork Tue Mar 5 16:12:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1908339 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=pjzSR8FW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Tq0w36cjXz23fC 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 D5CBD3858000 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 sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by sourceware.org (Postfix) with ESMTPS id 2C6A43858C54 for ; Tue, 5 Mar 2024 16:12:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C6A43858C54 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 2C6A43858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=145.40.73.55 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655151; cv=none; b=vi1pBi9/mzJ4xtP9GhNdeM76s6sKjNifHzYuCYYlzOmNTXTCnVcf2yOtc5pMNPmV479eisDMW28LeRQrevF2fQfpEvEWImaaIChp+mcVku+bp20xyeTX9s4MVB+vdXSyrXnwbTGZTlFSOU1m0y7GdlRJNemGXXC4Mm5B/E5mWsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655151; c=relaxed/simple; bh=YozYzgOuUp22XBT8QV+vVul7306BUFdJJqJVHBgI+Ys=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Tk4Vun/+pXw2742AVRYU59agWiDaFtD9jg4oW0zaGfZOX5NfIbq7fHwFny187pJ34PeZA7VFwcmaBclHCu919NXnW1Vs01m6RPgo7ZVMe3418fQ1tpTSt4+lga/4zHkhKrQ9vTjk6rA9h9FTdjzRMlJ3qSSOJloKjSo3QllDfdU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C226BCE13A6; Tue, 5 Mar 2024 16:12:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E8DC433F1; Tue, 5 Mar 2024 16:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709655145; bh=YozYzgOuUp22XBT8QV+vVul7306BUFdJJqJVHBgI+Ys=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pjzSR8FW6zgdxtt2LlBWvPq6sYq6xRBEZr6Wqa1epXrNDN9WbRwj54jTH4JIrTk1E 66zPeYU8bBbQD00pHnOp59jvR0EWLUvJshDTJWsTcbHlDUzcgaNAF4LNf6aRm9KHDg 1y2qEqJyKkBBmm7OyngJq/bfwatSxYSowbsnG3VOTlUoAqYqPq3c6E+me3u13plopf A7W/NRmIf73IslM2zLtck6hwsZvAx68MyMpCjYjg/c6sOo2/H1Wu87A5s96l17bV7/ 7pubb49hzLVgtrbXFj2EoOTK42hCNHrrqz3nAAeNN4yIHsYMzmO3S9mljw0xcWho5u 1Vcd+wJRedAEA== Date: Tue, 5 Mar 2024 17:12:23 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Morten Welinder , Vincent Lefevre , Adhemerval Zanella Netto Subject: [PATCH v2 1/3] manual: logb(x) is floor(log2(fabs(x))) Message-ID: <20240305161213.14364-2-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.4 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 log2(3) doesn't accept negative input, but it seems logb(3) does accept it. Link: Reported-by: Morten Welinder Cc: Adhemerval Zanella Netto Cc: Vincent Lefevre Signed-off-by: Alejandro Colomar --- manual/math.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/math.texi b/manual/math.texi index 2f6ee253b9..c54eaebb65 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -561,7 +561,7 @@ These functions return the base-2 logarithm of @var{x}. @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 (x))}, except it's probably faster. +to @code{floor (log2 (fabs (x)))}, except it's probably faster. 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 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 From patchwork Tue Mar 5 16:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1908340 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=OA6rGrxQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Tq0ws2Xf9z23cw for ; Wed, 6 Mar 2024 03:13:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A3D73858287 for ; Tue, 5 Mar 2024 16:13:31 +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 [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id 647FF3858296 for ; Tue, 5 Mar 2024 16:12:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 647FF3858296 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 647FF3858296 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655157; cv=none; b=m1GhntWNlHFuyA61JywB1XdGB9X0I0knUW/fYD7zxjQYI8Tq/lz7z9bARkPpvPTmWMN7MwQwgKRGEtRO65oH6mHIBVmkmrYYaxuanTLRkY2ydVVo/ZTqJJ8q+YXkhl2qDzV22pdm0S1DqGEZvuJFcQ4JlFra38ptvTYuhEbbUd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709655157; c=relaxed/simple; bh=4UUBYsUKFvSfKYpX6qjeKWVk0IK/yhTsdji6Gjr1hBM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=aIOaxeJfgu0vVBD3Z1/IljmU4z2KnnMyR4E+N1pXm39H2leEK5Pq2ld9AARWUq8c3ejyLogd8sNDfDVODBfEfsLXI4XsqdCZG5GTDADY0CkDk0PyRAXm02LfYvQCs351613BSZbZALP+D+/xC2IwB4mxnHNgJxPrna0DdjUVQVU= 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 C7A1761361; Tue, 5 Mar 2024 16:12:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34E03C433C7; Tue, 5 Mar 2024 16:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709655153; bh=4UUBYsUKFvSfKYpX6qjeKWVk0IK/yhTsdji6Gjr1hBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OA6rGrxQxZv/2po8/WvRaZHpTjUmjRsXK5nxWVQVObLAwna+jHDHyLKK19fDGWyiR bfMkKdoPXI3lXXjjymhKhsrCvOaWMy3XbOd5k+Lun/03CIwpWMEyHDJ80S64GHNt5Y z0YAvrYtyPsJxC7UeOcsrCK7QWWtwr4Cj3Mi3b/8+Ouugk3nfODaISLN6JjslTzpkg OjWFevYULszqaI38MQeUizvRMr0MTq6FCO8H0YCxQPd87a//o8rpdOc7GGf6f/l9ys RO9VfgWIqzkPBrrmIdA6DPH3DwTsjm/EcqS9Znhljucyh/z7SqaFhH6Cgd7Hvq+1RU m+mcv2Qm4AV5A== Date: Tue, 5 Mar 2024 17:12:30 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Morten Welinder , Vincent Lefevre , Adhemerval Zanella Netto Subject: [PATCH v2 3/3] manual: Cube roots are rarely representable Message-ID: <20240305161213.14364-4-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: Morten Welinder Cowritten-by: Morten Welinder Cc: Adhemerval Zanella Netto Cc: Vincent Lefevre Signed-off-by: Alejandro Colomar --- manual/math.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manual/math.texi b/manual/math.texi index 79bf3a1401..dfb685a71e 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -700,8 +700,12 @@ Mathematically, it should return a complex number. @standardsx{cbrtfN, TS 18661-3:2015, math.h} @standardsx{cbrtfNx, TS 18661-3:2015, math.h} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} -These functions return the cube root of @var{x}. They cannot -fail; every representable real value has a representable real cube root. +These functions return the cube root of @var{x}. +They cannot fail; +every representable real value +has a real cube root, +and rounding it to a representable value +never causes overflow nor underflow. @end deftypefun @deftypefun double hypot (double @var{x}, double @var{y})