Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250127152204.GQ10433@brightrain.aerifal.cx>
Date: Mon, 27 Jan 2025 10:22:04 -0500
From: Rich Felker <dalias@...c.org>
To: Damian McGuckin <damianm@....com.au>
Cc: MUSL <musl@...ts.openwall.com>
Subject: Re: Floating Point Mathematical Constanst in <math.h> ...

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 <math.h> 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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.