Skip to content

Commit

Permalink
8283124: Add constant for tau to Math and StrictMath
Browse files Browse the repository at this point in the history
Reviewed-by: bpb, iris
  • Loading branch information
jddarcy committed Mar 15, 2022
1 parent 671b6ef commit 05a83e0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/java.base/share/classes/java/lang/Math.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,24 @@ private Math() {}

/**
* The {@code double} value that is closer than any other to
* <i>pi</i>, the ratio of the circumference of a circle to its
* diameter.
* <i>pi</i> (&pi;), the ratio of the circumference of a circle to
* its diameter.
*/
public static final double PI = 3.141592653589793;

/**
* The {@code double} value that is closer than any other to
* <i>tau</i> (&tau;), the ratio of the circumference of a circle
* to its radius.
*
* @apiNote
* The value of <i>pi</i> is one half that of <i>tau</i>; in other
* words, <i>tau</i> is double <i>pi</i> .
*
* @since 19
*/
public static final double TAU = 2.0 * PI;

/**
* Constant by which to multiply an angular value in degrees to obtain an
* angular value in radians.
Expand Down
15 changes: 14 additions & 1 deletion src/java.base/share/classes/java/lang/StrictMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,24 @@ private StrictMath() {}

/**
* The {@code double} value that is closer than any other to
* <i>pi</i>, the ratio of the circumference of a circle to its
* <i>pi</i> (&pi;), the ratio of the circumference of a circle to its
* diameter.
*/
public static final double PI = 3.141592653589793;

/**
* The {@code double} value that is closer than any other to
* <i>tau</i> (&tau;), the ratio of the circumference of a circle
* to its radius.
*
* @apiNote
* The value of <i>pi</i> is one half that of <i>tau</i>; in other
* words, <i>tau</i> is double <i>pi</i> .
*
* @since 19
*/
public static final double TAU = 2.0 * PI;

/**
* Returns the trigonometric sine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
Expand Down

1 comment on commit 05a83e0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.