Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001503 [Issue 8 drafts] Base Definitions and Headers Editorial Enhancement Request 2021-08-07 20:59 2021-08-07 21:41
Reporter andras_farkas View Status public  
Assigned To
Priority normal Resolution Open  
Status New   Product Version
Name Andras Farkas
Organization
User Reference
Section math.h
Page Number
Line Number
Final Accepted Text
Summary 0001503: Potential new M_ constants for math.h
Description There 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 Action I'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.
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0005430)
andras_farkas (reporter)
2021-08-07 21:32

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.
(0005431)
andras_farkas (reporter)
2021-08-07 21:41

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

- 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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker