JavaScript is disabled on your browser.
javolution.lang

Class MathLib

    • Field Summary

      Fields
      Modifier and Type Field and Description
      static double E
      The natural logarithm.
      static double FOUR_PI
      Four time the ratio of the circumference of a circle to its diameter.
      static double HALF_PI
      Half the ratio of the circumference of a circle to its diameter.
      static double Infinity
      Infinity.
      static double LOG10
      The natural logarithm of ten.
      static double LOG2
      The natural logarithm of two.
      static double NaN
      Not-A-Number.
      static double PI
      The ratio of the circumference of a circle to its diameter.
      static double PI_SQUARE
      Holds PI * PI.
      static double SQRT2
      The square root of two.
      static double TWO_PI
      Twice the ratio of the circumference of a circle to its diameter.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      static double abs (double d)
      Returns the absolute value of the specified double argument.
      static float abs (float f)
      Returns the absolute value of the specified float argument.
      static int abs (int i)
      Returns the absolute value of the specified int argument.
      static long abs (long l)
      Returns the absolute value of the specified long argument.
      static double acos (double x)
      Returns the arc cosine of the specified value, in the range of 0.0 through pi.
      static double asin (double x)
      Returns the arc sine of the specified value, in the range of -pi/2 through pi/2.
      static double atan (double x)
      Returns the arc tangent of the specified value, in the range of -pi/2 through pi/2.
      static double atan2 (double y, double x)
      Returns the angle theta such that (x == cos(theta)) && (y == sin(theta)).
      static int bitCount (long longValue)
      Returns the number of one-bits in the two's complement binary representation of the specified long value.
      static int bitLength (int i)
      Returns the number of bits in the minimal two's-complement representation of the specified int, excluding a sign bit.
      static int bitLength (long l)
      Returns the number of bits in the minimal two's-complement representation of the specified long, excluding a sign bit.
      static double ceil (double x)
      Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.
      static double cos (double radians)
      Returns the trigonometric cosine of the specified angle in radians.
      static double cosh (double x)
      Returns the hyperbolic cosine of x.
      static int digitLength (int i)
      Returns the number of digits of the decimal representation of the specified int value, excluding the sign character if any.
      static int digitLength (long l)
      Returns the number of digits of the decimal representation of the the specified long, excluding the sign character if any.
      static double exp (double x)
      Returns e raised to the specified power.
      static double floor (double x)
      Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
      static int floorLog10 (double d)
      Returns the largest power of 10 that is less than or equal to the the specified positive value.
      static int floorLog2 (double d)
      Returns the largest power of 2 that is less than or equal to the the specified positive value.
      static double log (double x)
      Returns the natural logarithm (base e ) of the specified value.
      static double log10 (double x)
      Returns the decimal logarithm of the specified value.
      static double max (double x, double y)
      Returns the greater of two double values.
      static float max (float x, float y)
      Returns the greater of two float values.
      static int max (int x, int y)
      Returns the greater of two int values.
      static long max (long x, long y)
      Returns the greater of two long values.
      static double min (double x, double y)
      Returns the smaller of two double values.
      static float min (float x, float y)
      Returns the smaller of two float values.
      static int min (int x, int y)
      Returns the smaller of two int values.
      static long min (long x, long y)
      Returns the smaller of two long values.
      static int numberOfLeadingZeros (long longValue)
      Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long value.
      static int numberOfTrailingZeros (long longValue)
      Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long value.
      static double pow (double x, double y)
      Returns the value of the first argument raised to the power of the second argument.
      static double rem (double x, double y)
      Returns the remainder of the division of the specified two arguments.
      static long round (double d)
      Returns the closest long to the specified argument.
      static int round (float f)
      Returns the closest int to the specified argument.
      static double sin (double radians)
      Returns the trigonometric sine of the specified angle in radians.
      static double sinh (double x)
      Returns the hyperbolic sine of x.
      static double sqrt (double x)
      Returns the positive square root of the specified value.
      static double tan (double radians)
      Returns the trigonometric tangent of the specified angle in radians.
      static double tanh (double x)
      Returns the hyperbolic tangent of x.
      static double toDegrees (double radians)
      Converts an angle in radians to degrees.
      static double toDoublePow10 (long m, int n)
      Returns the closest double representation of the specified long number multiplied by a power of ten.
      static double toDoublePow2 (long m, int n)
      Returns the closest double representation of the specified long number multiplied by a power of two.
      static long toLongPow10 (double d, int n)
      Returns the closest long representation of the specified double number multiplied by a power of ten.
      static long toLongPow2 (double d, int n)
      Returns the closest long representation of the specified double number multiplied by a power of two.
      static double toRadians (double degrees)
      Converts an angle in degrees to radians.
    • Field Detail

      • PI

        public static final double PI
        The ratio of the circumference of a circle to its diameter.
        See Also:
        Constant Field Values
      • HALF_PI

        public static final double HALF_PI
        Half the ratio of the circumference of a circle to its diameter.
        See Also:
        Constant Field Values
      • TWO_PI

        public static final double TWO_PI
        Twice the ratio of the circumference of a circle to its diameter.
        See Also:
        Constant Field Values
      • FOUR_PI

        public static final double FOUR_PI
        Four time the ratio of the circumference of a circle to its diameter.
        See Also:
        Constant Field Values
    • Method Detail

      • bitLength

        public static int bitLength(int i)
        Returns the number of bits in the minimal two's-complement representation of the specified int, excluding a sign bit. For positive int, this is equivalent to the number of bits in the ordinary binary representation. For negative int, it is equivalent to the number of bits of the positive value -(i + 1).
        Parameters:
        i - the int value for which the bit length is returned.
        Returns:
        the bit length of i.
      • bitLength

        public static int bitLength(long l)
        Returns the number of bits in the minimal two's-complement representation of the specified long, excluding a sign bit. For positive long, this is equivalent to the number of bits in the ordinary binary representation. For negative long, it is equivalent to the number of bits of the positive value -(l + 1).
        Parameters:
        l - the long value for which the bit length is returned.
        Returns:
        the bit length of l.
      • bitCount

        public static int bitCount(long longValue)
        Returns the number of one-bits in the two's complement binary representation of the specified long value. This function is sometimes referred to as the population count.
        Parameters:
        longValue - the long value.
        Returns:
        the number of one-bits in the two's complement binary representation of the specified longValue.
      • numberOfLeadingZeros

        public static int numberOfLeadingZeros(long longValue)
        Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long value. Returns 64 if the specifed value is zero.
        Parameters:
        longValue - the long value.
        Returns:
        the number of leading zero bits.
      • numberOfTrailingZeros

        public static int numberOfTrailingZeros(long longValue)
        Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long value. Returns 64 if the specifed value is zero.
        Parameters:
        longValue - the long value.
        Returns:
        the number of trailing zero bits.
      • digitLength

        public static int digitLength(int i)
        Returns the number of digits of the decimal representation of the specified int value, excluding the sign character if any.
        Parameters:
        i - the int value for which the digit length is returned.
        Returns:
        String.valueOf(i).length() for zero or positive values; String.valueOf(i).length() - 1 for negative values.
      • digitLength

        public static int digitLength(long l)
        Returns the number of digits of the decimal representation of the the specified long, excluding the sign character if any.
        Parameters:
        l - the long value for which the digit length is returned.
        Returns:
        String.valueOf(l).length() for zero or positive values; String.valueOf(l).length() - 1 for negative values.
      • toDoublePow2

        public static double toDoublePow2(long m,
         int n)
        Returns the closest double representation of the specified long number multiplied by a power of two.
        Parameters:
        m - the long multiplier.
        n - the power of two exponent.
        Returns:
        m * 2n.
      • toDoublePow10

        public static double toDoublePow10(long m,
         int n)
        Returns the closest double representation of the specified long number multiplied by a power of ten.
        Parameters:
        m - the long multiplier.
        n - the power of ten exponent.
        Returns:
        multiplier * 10n.
      • toLongPow2

        public static long toLongPow2(double d,
         int n)
        Returns the closest long representation of the specified double number multiplied by a power of two.
        Parameters:
        d - the double multiplier.
        n - the power of two exponent.
        Returns:
        d * 2n
        Throws:
        ArithmeticException - if the conversion cannot be performed (NaN, Infinity or overflow).
      • toLongPow10

        public static long toLongPow10(double d,
         int n)
        Returns the closest long representation of the specified double number multiplied by a power of ten.
        Parameters:
        d - the double multiplier.
        n - the power of two exponent.
        Returns:
        d * 10n.
      • floorLog2

        public static int floorLog2(double d)
        Returns the largest power of 2 that is less than or equal to the the specified positive value.
        Parameters:
        d - the double number.
        Returns:
        floor(Log2(abs(d)))
        Throws:
        ArithmeticException - if d <= 0 or d is NaN or Infinity.
      • floorLog10

        public static int floorLog10(double d)
        Returns the largest power of 10 that is less than or equal to the the specified positive value.
        Parameters:
        d - the double number.
        Returns:
        floor(Log10(abs(d)))
        Throws:
        ArithmeticException - if d <= 0 or d is NaN or Infinity.
      • toRadians

        public static double toRadians(double degrees)
        Converts an angle in degrees to radians.
        Parameters:
        degrees - the angle in degrees.
        Returns:
        the specified angle in radians.
      • toDegrees

        public static double toDegrees(double radians)
        Converts an angle in radians to degrees.
        Parameters:
        radians - the angle in radians.
        Returns:
        the specified angle in degrees.
      • sqrt

        public static double sqrt(double x)
        Returns the positive square root of the specified value.
        Parameters:
        x - the value.
        Returns:
        java.lang.Math.sqrt(x)
      • rem

        public static double rem(double x,
         double y)
        Returns the remainder of the division of the specified two arguments.
        Parameters:
        x - the dividend.
        y - the divisor.
        Returns:
        x - round(x / y) * y
      • ceil

        public static double ceil(double x)
        Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.
        Parameters:
        x - the value.
        Returns:
        java.lang.Math.ceil(x)
      • floor

        public static double floor(double x)
        Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
        Parameters:
        x - the value.
        Returns:
        java.lang.Math.ceil(x)
      • sin

        public static double sin(double radians)
        Returns the trigonometric sine of the specified angle in radians.
        Parameters:
        radians - the angle in radians.
        Returns:
        java.lang.Math.sin(radians)
      • cos

        public static double cos(double radians)
        Returns the trigonometric cosine of the specified angle in radians.
        Parameters:
        radians - the angle in radians.
        Returns:
        java.lang.Math.cos(radians)
      • tan

        public static double tan(double radians)
        Returns the trigonometric tangent of the specified angle in radians.
        Parameters:
        radians - the angle in radians.
        Returns:
        java.lang.Math.tan(radians)
      • asin

        public static double asin(double x)
        Returns the arc sine of the specified value, in the range of -pi/2 through pi/2.
        Parameters:
        x - the value whose arc sine is to be returned.
        Returns:
        the arc sine in radians for the specified value.
      • acos

        public static double acos(double x)
        Returns the arc cosine of the specified value, in the range of 0.0 through pi.
        Parameters:
        x - the value whose arc cosine is to be returned.
        Returns:
        the arc cosine in radians for the specified value.
      • atan

        public static double atan(double x)
        Returns the arc tangent of the specified value, in the range of -pi/2 through pi/2.
        Parameters:
        x - the value whose arc tangent is to be returned.
        Returns:
        the arc tangent in radians for the specified value.
        See Also:
        Inverse Tangent -- from MathWorld
      • atan2

        public static double atan2(double y,
         double x)
        Returns the angle theta such that (x == cos(theta)) && (y == sin(theta)).
        Parameters:
        y - the y value.
        x - the x value.
        Returns:
        the angle theta in radians.
        See Also:
        Wikipedia: Atan2
      • sinh

        public static double sinh(double x)
        Returns the hyperbolic sine of x.
        Parameters:
        x - the value for which the hyperbolic sine is calculated.
        Returns:
        (exp(x) - exp(-x)) / 2
      • cosh

        public static double cosh(double x)
        Returns the hyperbolic cosine of x.
        Parameters:
        x - the value for which the hyperbolic cosine is calculated.
        Returns:
        (exp(x) + exp(-x)) / 2
      • tanh

        public static double tanh(double x)
        Returns the hyperbolic tangent of x.
        Parameters:
        x - the value for which the hyperbolic tangent is calculated.
        Returns:
        (exp(2 * x) - 1) / (exp(2 * x) + 1)
      • log

        public static double log(double x)
        Returns the natural logarithm (base e ) of the specified value.
        Parameters:
        x - the value greater than 0.0.
        Returns:
        the value y such as ey == x
      • log10

        public static double log10(double x)
        Returns the decimal logarithm of the specified value.
        Parameters:
        x - the value greater than 0.0.
        Returns:
        the value y such as 10y == x
      • pow

        public static double pow(double x,
         double y)
        Returns the value of the first argument raised to the power of the second argument.
        Parameters:
        x - the base.
        y - the exponent.
        Returns:
        xy
      • round

        public static int round(float f)
        Returns the closest int to the specified argument.
        Parameters:
        f - the float value to be rounded to a int
        Returns:
        the nearest int value.
      • round

        public static long round(double d)
        Returns the closest long to the specified argument.
        Parameters:
        d - the double value to be rounded to a long
        Returns:
        the nearest long value.
      • abs

        public static int abs(int i)
        Returns the absolute value of the specified int argument.
        Parameters:
        i - the int value.
        Returns:
        i or -i
      • abs

        public static long abs(long l)
        Returns the absolute value of the specified long argument.
        Parameters:
        l - the long value.
        Returns:
        l or -l
      • abs

        public static float abs(float f)
        Returns the absolute value of the specified float argument.
        Parameters:
        f - the float value.
        Returns:
        f or -f
      • abs

        public static double abs(double d)
        Returns the absolute value of the specified double argument.
        Parameters:
        d - the double value.
        Returns:
        d or -d
      • max

        public static int max(int x,
         int y)
        Returns the greater of two int values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the larger of x and y.
      • max

        public static long max(long x,
         long y)
        Returns the greater of two long values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the larger of x and y.
      • max

        public static float max(float x,
         float y)
        Returns the greater of two float values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the larger of x and y.
      • max

        public static double max(double x,
         double y)
        Returns the greater of two double values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the larger of x and y.
      • min

        public static int min(int x,
         int y)
        Returns the smaller of two int values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the smaller of x and y.
      • min

        public static long min(long x,
         long y)
        Returns the smaller of two long values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the smaller of x and y.
      • min

        public static float min(float x,
         float y)
        Returns the smaller of two float values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the smaller of x and y.
      • min

        public static double min(double x,
         double y)
        Returns the smaller of two double values.
        Parameters:
        x - the first value.
        y - the second value.
        Returns:
        the smaller of x and y.

Copyright © 2005-2013 Javolution. All Rights Reserved.

AltStyle によって変換されたページ (->オリジナル) /