View Issue Details

IDProjectCategoryView StatusLast Update
0001503Issue 8 draftsBase Definitions and Headerspublic2024-06-11 09:12
Reporterandras_farkas Assigned To 
PrioritynormalSeverityEditorialTypeEnhancement Request
Status ClosedResolutionAccepted As Marked 
NameAndras Farkas
Organization
User Reference
Sectionmath.h
Page Number
Line Number
Final Accepted Text0001503:0005541
Summary0001503: Potential new M_ constants for math.h
DescriptionThere may be five useful new M_ constants to be included in the math.h header.

The latest standard for C++, known as C++20, introduces a header called <numbers>, which contains many math constants, and is similar in intent to XSI's M_ constants in math.h. There's lots of overlap, but the list of M_ constants and list of constants in <numbers> do differ.

Constants in both XSI and <numbers>:
M_E, e
M_LOG2E, log2e
M_LOG10E, log10e
M_LN2, ln2
M_LN10, ln10
M_PI, pi
M_1_PI, inv_pi
M_SQRT2, sqrt2

Constants only in XSI:
M_PI_2
M_PI_4
M_2_PI
M_2_SQRTPI
M_SQRT1_2

Constants only in <numbers>:
inv_sqrtpi (1 divided by the square root of pi, approximately 0.5641)
sqrt3 (Square root of 3, approximately 1.7320)
inv_sqrt3 (1 divided by the square root of 3, approximately 0.5773)
egamma (Euler-Mascheroni constant, approximately 0.5772)
phi (golden ratio, approximately 1.6180)

References:
XSI:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html
C++20 draft standard (specifically section 26.9, page 1224):
https://isocpp.org/files/papers/N4860.pdf
P0631R8 Math Constants (The original paper on <numbers>):
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0631r8.pdf
Notably, this paper references XSI.

I'm not a mathematician, so I'm not sure whether adding those five new constants from <numbers> would be considered useful, or considered clutter. Please chime in.
Personally, I've only ever used M_PI out of all the M_ constants, but I'm glad it's there when I do use it, and I'm glad all the constants are there.
Desired ActionI'd like for people to examine the usefulness of the five new constants. If they're judged useful:
Add to the section on math.h, immediately after the other M_ constants (or interspersed with them), and also XSI-marked:
M_1_SQRTPI
Value of 1/sqrt(pi)
M_SQRT3
Value of sqrt(3)
M_1_SQRT3
Value of 1/sqrt(3)
M_EGAMMA
Value of [lower-case gamma], Euler-Mascheroni constant
M_PHI
Value of [lower-case phi], ( (1 + sqrt(5))/2 ), golden ratio constant

Of course, the "Value of" text would use more fitting symbols than I was able to use here, for the values.
Tagsissue8

Activities

andras_farkas

2021-08-07 21:32

reporter   bugnote:0005430

Actually, there could be some changes to my desired action proposal.
M_1_SQRT3 should certainly be M_SQRT1_3 in order to match M_SQRT1_2
M_1_SQRTPI could also be M_SQRT1_PI to match.

andras_farkas

2021-08-07 21:41

reporter   bugnote:0005431

Thus, desiring to be consistent with the standard as it already exists, this is my new desired action:
Add to the section on math.h, immediately after the other M_ constants (or interspersed with them), and also XSI-marked:
M_SQRT1_PI
Value of 1/sqrt(pi)
M_SQRT3
Value of sqrt(3)
M_SQRT1_3
Value of 1/sqrt(3)
M_EGAMMA
Value of [lower-case gamma], Euler-Mascheroni constant
M_PHI
Value of [lower-case phi], ( (1 + sqrt(5))/2 ), golden ratio constant

geoffclare

2021-12-02 17:24

manager   bugnote:0005541

Last edited: 2021-12-02 17:39

Add the requested new M_ symbolic constants to <math.h> using the names in 0001503:0005431 in an order determined by the editor all with XSI shading.
Also add XSI shading to (2018 edition) P288, L9745-9746 and extend the shading down to L9759 (as a single shading block).

geoffclare

2022-01-13 10:13

manager   bugnote:0005598

While applying this bug, on seeing the updated list with the additions in place, I decided it made more sense to add the name M_1_SQRTPI from the Desired Action, instead of M_SQRT1_PI, so that it forms a consistent set with M_1_PI, M_2_PI, and M_2_SQRTPI.

Issue History

Date Modified Username Field Change
2021-08-07 20:59 andras_farkas New Issue
2021-08-07 20:59 andras_farkas Name => Andras Farkas
2021-08-07 20:59 andras_farkas Section => math.h
2021-08-07 21:32 andras_farkas Note Added: 0005430
2021-08-07 21:41 andras_farkas Note Added: 0005431
2021-12-02 17:24 geoffclare Note Added: 0005541
2021-12-02 17:25 geoffclare Final Accepted Text => 0001503:0005541
2021-12-02 17:25 geoffclare Status New => Resolved
2021-12-02 17:25 geoffclare Resolution Open => Accepted As Marked
2021-12-02 17:25 geoffclare Tag Attached: issue8
2021-12-02 17:39 geoffclare Note Edited: 0005541
2022-01-13 10:13 geoffclare Note Added: 0005598
2022-01-13 10:13 geoffclare Status Resolved => Applied
2024-06-11 09:12 agadmin Status Applied => Closed