src/java.base/share/classes/java/lang/Math.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8076112 Cdiff src/java.base/share/classes/java/lang/Math.java

src/java.base/share/classes/java/lang/Math.java

Print this page

        

*** 22,35 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package java.lang; - import java.util.Random; import sun.misc.FloatConsts; import sun.misc.DoubleConsts; /** * The class {@code Math} contains methods for performing basic * numeric operations such as the elementary exponential, logarithm, * square root, and trigonometric functions. --- 22,36 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package java.lang; + import java.util.Random; import sun.misc.FloatConsts; import sun.misc.DoubleConsts; + import jdk.internal.HotSpotIntrinsicCandidate; /** * The class {@code Math} contains methods for performing basic * numeric operations such as the elementary exponential, logarithm, * square root, and trigonometric functions.
*** 145,154 **** --- 146,156 ---- * Results must be semi-monotonic. * * @param a an angle, in radians. * @return the sine of the argument. */ + @HotSpotIntrinsicCandidate public static double sin(double a) { return StrictMath.sin(a); // default impl. delegates to StrictMath } /**
*** 160,169 **** --- 162,172 ---- * Results must be semi-monotonic. * * @param a an angle, in radians. * @return the cosine of the argument. */ + @HotSpotIntrinsicCandidate public static double cos(double a) { return StrictMath.cos(a); // default impl. delegates to StrictMath } /**
*** 177,186 **** --- 180,190 ---- * Results must be semi-monotonic. * * @param a an angle, in radians. * @return the tangent of the argument. */ + @HotSpotIntrinsicCandidate public static double tan(double a) { return StrictMath.tan(a); // default impl. delegates to StrictMath } /**
*** 278,287 **** --- 282,292 ---- * * @param a the exponent to raise <i>e</i> to. * @return the value <i>e</i><sup>{@code a}</sup>, * where <i>e</i> is the base of the natural logarithms. */ + @HotSpotIntrinsicCandidate public static double exp(double a) { return StrictMath.exp(a); // default impl. delegates to StrictMath } /**
*** 299,308 **** --- 304,314 ---- * * @param a a value * @return the value ln&nbsp;{@code a}, the natural logarithm of * {@code a}. */ + @HotSpotIntrinsicCandidate public static double log(double a) { return StrictMath.log(a); // default impl. delegates to StrictMath } /**
*** 324,333 **** --- 330,340 ---- * * @param a a value * @return the base 10 logarithm of {@code a}. * @since 1.5 */ + @HotSpotIntrinsicCandidate public static double log10(double a) { return StrictMath.log10(a); // default impl. delegates to StrictMath } /**
*** 345,354 **** --- 352,362 ---- * * @param a a value. * @return the positive square root of {@code a}. * If the argument is NaN or less than zero, the result is NaN. */ + @HotSpotIntrinsicCandidate public static double sqrt(double a) { return StrictMath.sqrt(a); // default impl. delegates to StrictMath // Note that hardware sqrt instructions // frequently can be directly used by JITs // and should be much faster than doing
*** 523,532 **** --- 531,541 ---- * @return the <i>theta</i> component of the point * (<i>r</i>,&nbsp;<i>theta</i>) * in polar coordinates that corresponds to the point * (<i>x</i>,&nbsp;<i>y</i>) in Cartesian coordinates. */ + @HotSpotIntrinsicCandidate public static double atan2(double y, double x) { return StrictMath.atan2(y, x); // default impl. delegates to StrictMath } /**
*** 650,659 **** --- 659,669 ---- * * @param a the base. * @param b the exponent. * @return the value {@code a}<sup>{@code b}</sup>. */ + @HotSpotIntrinsicCandidate public static double pow(double a, double b) { return StrictMath.pow(a, b); // default impl. delegates to StrictMath } /**
*** 804,813 **** --- 814,824 ---- * @param y the second value * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int addExact(int x, int y) { int r = x + y; // HD 2-12 Overflow iff both arguments have the opposite sign of the result if (((x ^ r) & (y ^ r)) < 0) { throw new ArithmeticException("integer overflow");
*** 823,832 **** --- 834,844 ---- * @param y the second value * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long addExact(long x, long y) { long r = x + y; // HD 2-12 Overflow iff both arguments have the opposite sign of the result if (((x ^ r) & (y ^ r)) < 0) { throw new ArithmeticException("long overflow");
*** 842,851 **** --- 854,864 ---- * @param y the second value to subtract from the first * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int subtractExact(int x, int y) { int r = x - y; // HD 2-12 Overflow iff the arguments have different signs and // the sign of the result is different than the sign of x if (((x ^ y) & (x ^ r)) < 0) {
*** 862,871 **** --- 875,885 ---- * @param y the second value to subtract from the first * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long subtractExact(long x, long y) { long r = x - y; // HD 2-12 Overflow iff the arguments have different signs and // the sign of the result is different than the sign of x if (((x ^ y) & (x ^ r)) < 0) {
*** 882,891 **** --- 896,906 ---- * @param y the second value * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int multiplyExact(int x, int y) { long r = (long)x * (long)y; if ((int)r != r) { throw new ArithmeticException("integer overflow"); }
*** 900,909 **** --- 915,925 ---- * @param y the second value * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long multiplyExact(long x, long y) { long r = x * y; long ax = Math.abs(x); long ay = Math.abs(y); if (((ax | ay) >>> 31 != 0)) {
*** 925,934 **** --- 941,951 ---- * @param a the value to increment * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int incrementExact(int a) { if (a == Integer.MAX_VALUE) { throw new ArithmeticException("integer overflow"); }
*** 942,951 **** --- 959,969 ---- * @param a the value to increment * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long incrementExact(long a) { if (a == Long.MAX_VALUE) { throw new ArithmeticException("long overflow"); }
*** 959,968 **** --- 977,987 ---- * @param a the value to decrement * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int decrementExact(int a) { if (a == Integer.MIN_VALUE) { throw new ArithmeticException("integer overflow"); }
*** 976,985 **** --- 995,1005 ---- * @param a the value to decrement * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long decrementExact(long a) { if (a == Long.MIN_VALUE) { throw new ArithmeticException("long overflow"); }
*** 993,1002 **** --- 1013,1023 ---- * @param a the value to negate * @return the result * @throws ArithmeticException if the result overflows an int * @since 1.8 */ + @HotSpotIntrinsicCandidate public static int negateExact(int a) { if (a == Integer.MIN_VALUE) { throw new ArithmeticException("integer overflow"); }
*** 1010,1019 **** --- 1031,1041 ---- * @param a the value to negate * @return the result * @throws ArithmeticException if the result overflows a long * @since 1.8 */ + @HotSpotIntrinsicCandidate public static long negateExact(long a) { if (a == Long.MIN_VALUE) { throw new ArithmeticException("long overflow"); }
*** 1254,1263 **** --- 1276,1286 ---- * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)} * * @param a the argument whose absolute value is to be determined * @return the absolute value of the argument. */ + @HotSpotIntrinsicCandidate public static double abs(double a) { return (a <= 0.0D) ? 0.0D - a : a; } /**
*** 1268,1277 **** --- 1291,1301 ---- * * @param a an argument. * @param b another argument. * @return the larger of {@code a} and {@code b}. */ + @HotSpotIntrinsicCandidate public static int max(int a, int b) { return (a >= b) ? a : b; } /**
*** 1352,1361 **** --- 1376,1386 ---- * * @param a an argument. * @param b another argument. * @return the smaller of {@code a} and {@code b}. */ + @HotSpotIntrinsicCandidate public static int min(int a, int b) { return (a <= b) ? a : b; } /**
src/java.base/share/classes/java/lang/Math.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File