From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 565DE21D2D for ; Mon, 27 Jan 2025 16:22:19 +0100 (CET) Received: (qmail 3344 invoked by uid 550); 27 Jan 2025 15:22:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com x-ms-reactions: disallow Received: (qmail 3317 invoked from network); 27 Jan 2025 15:22:14 -0000 Date: Mon, 27 Jan 2025 10:22:04 -0500 From: Rich Felker To: Damian McGuckin Cc: MUSL Message-ID: <20250127152204.GQ10433@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Floating Point Mathematical Constanst in ... On Sat, Jan 25, 2025 at 11:24:28AM +1100, Damian McGuckin wrote: > > This is not specific to MUSL but I figured the knowledge exists in > the list. I was doing a review for a small book I am writing. > > As long as one has > > defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) > > the constants > > M_E > M_LOG2E > M_LOG10E > M_LN2 > M_LN10 > M_2_SQRT_PI > > Has anybody been involved in the global 'need' of these constants, > i.e. how often they appear in people's code such that the names need > to be a > global identified as long as one includes both and does the > appropriate #defines. > > The reason I ask is that I cannot find where any of these is used in > elementary mathematical libraries such as MUSL. Nor can I find the > use > of Napier's constant (or Euler's number), i.e. 'e' or M_E, in a few > million lines of engineering and physics software to which I have > access. > > The average log() or log2() or log10() programs which one might > think could use those logarithm constants instead far more accurate > ones instead. > > I would like to say these constants have very little utility in the > average programmer of technical software for engineering or physics > but that might be a little extreme. > > Just curious. Sadly, the people who made that decision at Berkeley > in the eighties are quite hard to find these days, most of them > enjoying their well-earned retirements. My simple explanation would be that these constants are moderately useful to software consuming the standard math library and treating floating point numbers as a good approximation of the reals for specific real-world purposes, but that they're completely useless (inadequate) for implementing high-quality general-purpose math functions accurate across their entire domains. Rich