#404 closed defect (fixed)
psConstants.h defines unnecessary constants
| Reported by: | Paul Price | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | types | Version: | 0.5.0 |
| Severity: | trivial | Keywords: | |
| Cc: |
Description
psConstants.h contains the following definitions:
#define PS_ONE 1.0
#define PS_PI 3.1415926535897932384626433832795029 /* pi */
#define PS_PI_2 1.5707963267948966192313216916397514 /* pi/2 */
#define PS_PI_4 0.7853981633974483096156608458198757 /* pi/4 */
#define PS_1_PI 0.3183098861837906715377675267450287 /* 1/pi */
#define PS_2_PI 0.6366197723675813430755350534900574 /* 2/pi */
#define PS_COT(X) (1.0 / atan(X))
- It is unnecessary to define the value of 1.
- The multiples of pi are generally available in math.h (M_PI; though this may
be an extension).
- The definition of the co-tangent is incorrect --- it should be 1/tan(x).
Change History (5)
comment:1 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:2 by , 21 years ago
Since M_PI is so commonly used, let's do the following:
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795029
#endif
et cetera.
comment:3 by , 21 years ago
OK, fine. I changed all references of PS_PI* to M_PI* and just made sure M_PI
is defined.
-rdd

M_PI has problematic. It is not C99, Posix or ANSI C (our requirements); it is
a BSD/UNIX98 extension. It is also not available on all systems/compilers --
at least not by default. OSX is a prime example of that.
The PS_ONE and PS_COT both were not ever referenced, so I just removed them. I
know that PS_ONE had a purpose at one time, but I don't remember what that
could have been.