Skip to content

Commit

Permalink
Merge pull request #8 from jmcwilliams403/main
Browse files Browse the repository at this point in the history
Added float/double literals for sqrt 2/3/5
  • Loading branch information
tommyettinger committed Aug 8, 2022
2 parents 9ca6819 + 3dd8307 commit c0a86db
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/main/java/com/github/tommyettinger/digital/MathTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,50 @@ private MathTools() {
*/
public static final float E = 2.7182818284590452354f;

/**
* The {@code float} value that is closer than any other to
* {@code Math.sqrt(2.0)}, the ratio of the hypotenuse of an
* isosceles right triangle to one of its legs.
*/
public static final float ROOT2 = 1.4142135623730950488f;

/**
* The {@code double} value that is closer than any other to
* {@code Math.sqrt(2.0)}, the ratio of the hypotenuse of an
* isosceles right triangle to one of its legs.
*/
public static final double ROOT2_D = 1.4142135623730950488;

/**
* The {@code float} value that is closer than any other to
* {@code Math.sqrt(3.0)}, the ratio of the diagonal length
* of a cube to its edge length.
*/
public static final float ROOT3 = 1.7320508075688772935f;

/**
* The {@code double} value that is closer than any other to
* {@code Math.sqrt(3.0)}, the ratio of the diagonal length
* of a cube to its edge length.
*/
public static final double ROOT3_D = 1.7320508075688772935;

/**
* The {@code float} value that is closer than any other to
* {@code Math.sqrt(5.0)}, which has various useful properties,
* such as appearing in many formulae involving the golden ratio
* which is of course chiefly due to being part of its calculation.
*/
public static final float ROOT5 = 2.2360679774997896964f;

/**
* The {@code double} value that is closer than any other to
* {@code Math.sqrt(5.0)}, which has various useful properties,
* such as appearing in many formulae involving the golden ratio
* which is of course chiefly due to being part of its calculation.
*/
public static final double ROOT5_D = 2.2360679774997896964;

/**
* The famous golden ratio, {@code (1.0 + Math.sqrt(5.0)) * 0.5}; this is the "most irrational" of irrational
* numbers, and has various useful properties.
Expand Down

0 comments on commit c0a86db

Please sign in to comment.