From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by sourceware.org (Postfix) with ESMTPS id 128633858D37 for ; Mon, 4 Mar 2024 17:52:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 128633858D37 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 128633858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:40e1:4800::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709574745; cv=none; b=RxCNGXNMcLfw8EYu62kw+lw/VLjAcDvyC1eqVexCqtj7FIpdz+YHqkIX9UouJUc67OO9n08SrFKV0vUKNSbCja46u2jUrKepTPESpXp6YG4d0DVyN/NDQ+GlzKdJ1fCzsTIIODVltkFy0TwFIqabFjrWR6HJsYfj7uXF3h+2Agc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709574745; c=relaxed/simple; bh=Q2VTBJvRm67nWQA4o9Y0sJjcx1BYodhXuxxGA9Wof40=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=wX3rh+G5Jt1mB7hZRNksvOOtgFSoGfhzUUhqyiC2TiOjB7wvEXq98K03aP41I4Clu9ReTMqfrsn+fbHxLDpVyShNqEx5dDb6Xu/542B/fU83xAmsrKwX7IZmHP5LN2SI4AEacZ6xPbzXUG8hRnnnbkSVcXKfKCJSDm2s01Vy9ac= 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 CC6BCCE1188; Mon, 4 Mar 2024 17:52:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B6C0C433F1; Mon, 4 Mar 2024 17:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709574740; bh=Q2VTBJvRm67nWQA4o9Y0sJjcx1BYodhXuxxGA9Wof40=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B8tTM4OOCtzJrIuWPpbLbDzhgnHNcAiUwPhUpu13ruPNiz8XzZadxLi8oCCz/d6th PVEsHXCbP/Q4XXE2khINJI2AZU1/0VFNRnAoOY5dzFd+8TQLw3JdWJt/HDDb1veCo+ 04YfOhCYQpXnP1n2Xzk+G9cn+b6Jhn8o/qNVZpZNC12T6CWPgyEyLHqo7ixDqk7c46 KtWwFxe07sVVuSBp7KJ+224SOuJvbv6WzHg5tXHTxRJ3XQSvVIwjXL32hbCHBavPmQ dJjQjnkoiD2cMf3pEWG7lnQ0laMMJ0uoObqoInubEKCkp9XFgjCEw49NeKzDmNSnnQ WAPAe0tTxGlow== Date: Mon, 4 Mar 2024 18:52:10 +0100 From: Alejandro Colomar To: Morten Welinder Cc: linux-man@vger.kernel.org, libc-help@sourceware.org Subject: logb() vs floor(log2()) (was: Man page issues: logb, significand, cbrt, log2, log10, exp10) Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Qt/6QOdeBIjdvKGJ" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: --Qt/6QOdeBIjdvKGJ Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Mon, 4 Mar 2024 18:52:10 +0100 From: Alejandro Colomar To: Morten Welinder Cc: linux-man@vger.kernel.org, libc-help@sourceware.org Subject: logb() vs floor(log2()) (was: Man page issues: logb, significand, cbrt, log2, log10, exp10) Hi Morten, On Thu, Feb 29, 2024 at 07:28:10PM -0500, Morten Welinder wrote: > I came across some minor issues in some math man pages. >=20 > M. >=20 >=20 >=20 > logb: > The formula "floor(log2(x))" should be "floor(log2(fabs(x)))". (Or > ...abs(...) if it's meant to be math and not C.) Confirmed. This is a bug in glibc too, BTW. That text seems to be copied from their manual. ISO C says this function is specified in ANSI/IEEE 854, but I don't have access to that document, so I'm not sure what's the specification of the function. I'm not sure if it should fail for negative values (like log2(3)) or not; although the standard mentions the behavior for negative infinity, so it probably is specified to work for negative values too. So, the behavior of the function seems to be correct, and it's just the manual that needs to be fixed. I've CCed glibc, in case they want to comment. But yeah, your suggestion seems correct. Have a lovely day! Alex --=20 Looking for a remote C programming job at the moment. --Qt/6QOdeBIjdvKGJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmXmCkoACgkQnowa+77/ 2zJruxAAmbixMiXdFwE83fEYTGrfPrlmuv1JpLODstsdRS2goJi5IuA+wf7ai/ye +yryD/gyezqhz67MQJSXOyJFq55C4xVpqldnJxv4Y06+JzOGZmDyOYkybwahwCR6 V2e0KCEQLHDlafqtFRv1tapfwzOVw/DAsRRcYd2VAgtmf6aIVvx8pry5yMyHPEsK 3JejwI9iaKZcRKzWiu5J9Mm/nnEyza0636hz9Oq8xmQ/PI/MDsq30+k71IchxRB/ C8uUC0SFRwtP/97oC+S40L7xCjnHof0MVUH7I7uhE1CIh+DNbdbwnWnNmcDt82o6 m7m97DjxFJ11zPND+PZ/RQCukCCkgyps1LaYIKgDIhiXuRf6H7x9zUs3Sau8dpGf 3M/z7exqpRonlakwaPhqMdo3Iqhwy7wihV+wMfnRKAry+5ZwCVN5J60pgn7PBM+G C8SQHpPlgsfNPYEorZRMLEzBhxDq1Ll6ny88p5XU3OOu309G8dGxMxSBdy8jBveg HXkWg8agR3lnr1MfJMkOg1htVEcWg8zJiRexpyNS/Xx43NtLNpkMQIXd2IV+QG/g 3O3H3cpJ68Y8Du5QCVMJQaihbte1ss9iB7R7vhpqPKK2zOSp3xZPI5l36pTvAXSk NQIh79pq9xjzYIbhU/KMo5efmzYL7VA+tIQIqRLPeGAemt95waU= =in1C -----END PGP SIGNATURE----- --Qt/6QOdeBIjdvKGJ--