[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not par
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard |
Date: |
Thu, 13 Jan 2022 10:47:44 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 |
Follow-up Comment #2, bug #61812 (project octave):
These constants may not be part of the standard, but they are *really* widely
available.
I don't think we need to try for perfection here. If the Windows OS has a
special exception and doesn't include M_PI then let's just figure out a way to
include a definition for M_PI.
Some ideas:
1) Provide a wrapper for the the cmath header in liboctave/wrappers
2) Do a configure test for Windows and define _USE_MATH_DEFINES on that
platform
3) Define M_PI ourselves if it does not exist.
On a related note, this code for the pi() function in
libinterp/corefcn/data.cc is not the way to do it:
#if defined (M_PI)
double pi_val = M_PI;
#else
double pi_val = 4.0 * atan (1.0);
#endif
This requires calculating atan() every single time on platforms, like Windows,
which don't have M_PI built-in. At the very least the second half should be
tagged with constexpr (and maybe static too).
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61812>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard,
Rik <=
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Rik, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Rik, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, John W. Eaton, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard, Rik, 2022/01/13