## src/java.base/share/classes/java/lang/StrictMath.java

```rev 10702 : 4477961: java.lang.Math.toDegrees(double) could be optimized
Summary: Change toDegrees() and toRadians() to multiplication by a compile-time constant.
 ``` `````` 81 82 /** 83 * Don't let anyone instantiate this class. 84 */ 85 private StrictMath() {} 86 87 /** 88 * The {@code double} value that is closer than any other to 89 * e, the base of the natural logarithms. 90 */ 91 public static final double E = 2.7182818284590452354; 92 93 /** 94 * The {@code double} value that is closer than any other to 95 * pi, the ratio of the circumference of a circle to its 96 * diameter. 97 */ 98 public static final double PI = 3.14159265358979323846; 99 100 /** 101 * Returns the trigonometric sine of an angle. Special cases: 102 *
• If the argument is NaN or an infinity, then the 103 * result is NaN. 104 *
• If the argument is zero, then the result is a zero with the 105 * same sign as the argument.
106 * 107 * @param a an angle, in radians. 108 * @return the sine of the argument. 109 */ 110 public static native double sin(double a); 111 112 /** 113 * Returns the trigonometric cosine of an angle. Special cases: 114 *
• If the argument is NaN or an infinity, then the 115 * result is NaN.
116 * 117 * @param a an angle, in radians. 118 * @return the cosine of the argument. 119 */ 120 public static native double cos(double a); `````` 162 *
• If the argument is NaN, the result is NaN. 206 *
• If the argument is positive infinity, then the result is 207 * positive infinity. 208 *
• If the argument is negative infinity, then the result is 209 * positive zero.
210 * 211 * @param a the exponent to raise e to. 212 * @return the value e{@code a}, 213 * where e is the base of the natural logarithms. 214 */ 215 public static native double exp(double a); 216 217 /** 218 * Returns the natural logarithm (base e) of a {@code double} 219 * value. Special cases: ``` ``` `````` 81 82 /** 83 * Don't let anyone instantiate this class. 84 */ 85 private StrictMath() {} 86 87 /** 88 * The {@code double} value that is closer than any other to 89 * e, the base of the natural logarithms. 90 */ 91 public static final double E = 2.7182818284590452354; 92 93 /** 94 * The {@code double} value that is closer than any other to 95 * pi, the ratio of the circumference of a circle to its 96 * diameter. 97 */ 98 public static final double PI = 3.14159265358979323846; 99 100 /** 101 * Constant by which to multiply an angular value in degrees to obtain an 102 * angular value in radians. 103 */ 104 private static final double DEGREES_TO_RADIANS = 0.017453292519943295; 105 106 /** 107 * Constant by which to multiply an angular value in radians to obtain an 108 * angular value in degrees. 109 */ 110 111 private static final double RADIANS_TO_DEGREES = 57.29577951308232; 112 /** 113 * Returns the trigonometric sine of an angle. Special cases: 114 *
• If the argument is NaN or an infinity, then the 115 * result is NaN. 116 *
• If the argument is zero, then the result is a zero with the 117 * same sign as the argument.
118 * 119 * @param a an angle, in radians. 120 * @return the sine of the argument. 121 */ 122 public static native double sin(double a); 123 124 /** 125 * Returns the trigonometric cosine of an angle. Special cases: 126 *
• If the argument is NaN or an infinity, then the 127 * result is NaN.
128 * 129 * @param a an angle, in radians. 130 * @return the cosine of the argument. 131 */ 132 public static native double cos(double a); `````` 174 *