Package net.jafama

Class StrictFastMath

java.lang.Object
net.jafama.CmnFastMath
net.jafama.StrictFastMath

public final class StrictFastMath extends CmnFastMath
Strict versions of FastMath methods. Cf. README.txt for more info.
  • Field Details

    • USE_JDK_MATH

      private static final boolean USE_JDK_MATH
    • USE_REDEFINED_LOG

      private static final boolean USE_REDEFINED_LOG
    • USE_REDEFINED_SQRT

      private static final boolean USE_REDEFINED_SQRT
    • USE_POWTABS_FOR_ASIN

      private static final boolean USE_POWTABS_FOR_ASIN
      See Also:
  • Constructor Details

    • StrictFastMath

      private StrictFastMath()
      Non-instantiable.
  • Method Details

    • sin

      public static double sin(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle sine.
    • sinQuick

      public static double sinQuick(double angle)
      Quick sin, with accuracy of about 1.6e-3 (PI/invalid input: '<'look-up tabs size>) for |angle| invalid input: '<' 6588395.0 (Integer.MAX_VALUE * (2*PI/invalid input: '<'look-up tabs size>) - 2) (- 2 due to removing PI/2 before using cosine tab), and no accuracy at all for larger values.
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle sine.
    • cos

      public static double cos(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle cosine.
    • cosQuick

      public static double cosQuick(double angle)
      Quick cos, with accuracy of about 1.6e-3 (PI/invalid input: '<'look-up tabs size>) for |angle| invalid input: '<' 6588397.0 (Integer.MAX_VALUE * (2*PI/invalid input: '<'look-up tabs size>)), and no accuracy at all for larger values.
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle cosine.
    • sinAndCos

      public static double sinAndCos(double angle, DoubleWrapper cosine)
      Computes sine and cosine together.
      Parameters:
      angle - Angle in radians.
      cosine - (out) Angle cosine.
      Returns:
      Angle sine.
    • tan

      public static double tan(double angle)
      Can have very bad relative error near +-PI/2, but of the same magnitude than the relative delta between StrictMath.tan(PI/2) and StrictMath.tan(nextDown(PI/2)).
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle tangent.
    • asin

      public static double asin(double value)
      Parameters:
      value - Value in [-1,1].
      Returns:
      Value arcsine, in radians, in [-PI/2,PI/2].
    • asinInRange

      public static double asinInRange(double value)
      If value is not NaN and is outside [-1,1] range, closest value in this range is used.
      Parameters:
      value - Value in [-1,1].
      Returns:
      Value arcsine, in radians, in [-PI/2,PI/2].
    • acos

      public static double acos(double value)
      Parameters:
      value - Value in [-1,1].
      Returns:
      Value arccosine, in radians, in [0,PI].
    • acosInRange

      public static double acosInRange(double value)
      If value is not NaN and is outside [-1,1] range, closest value in this range is used.
      Parameters:
      value - Value in [-1,1].
      Returns:
      Value arccosine, in radians, in [0,PI].
    • atan

      public static double atan(double value)
      Parameters:
      value - A double value.
      Returns:
      Value arctangent, in radians, in [-PI/2,PI/2].
    • atan2

      public static double atan2(double y, double x)
      For special values for which multiple conventions could be adopted, behaves like StrictMath.atan2(double,double).
      Parameters:
      y - Coordinate on y axis.
      x - Coordinate on x axis.
      Returns:
      Angle from x axis positive side to (x,y) position, in radians, in [-PI,PI]. Angle measure is positive when going from x axis to y axis (positive sides).
    • toRadians

      public static double toRadians(double angdeg)
      Gives same result as StrictMath.toRadians for some particular values like 90.0, 180.0 or 360.0, but is faster (no division).
      Parameters:
      angdeg - Angle value in degrees.
      Returns:
      Angle value in radians.
    • toDegrees

      public static double toDegrees(double angrad)
      Gives same result as StrictMath.toDegrees for some particular values like Math.PI/2, Math.PI or 2*Math.PI, but is faster (no division).
      Parameters:
      angrad - Angle value in radians.
      Returns:
      Angle value in degrees.
    • toRadians

      public static double toRadians(boolean sign, int degrees, int minutes, double seconds)
      Parameters:
      sign - Sign of the angle: true for positive, false for negative.
      degrees - Degrees, in [0,180].
      minutes - Minutes, in [0,59].
      seconds - Seconds, in [0.0,60.0[.
      Returns:
      Angle in radians.
    • toDegrees

      public static double toDegrees(boolean sign, int degrees, int minutes, double seconds)
      Parameters:
      sign - Sign of the angle: true for positive, false for negative.
      degrees - Degrees, in [0,180].
      minutes - Minutes, in [0,59].
      seconds - Seconds, in [0.0,60.0[.
      Returns:
      Angle in degrees.
    • toDMS

      public static boolean toDMS(double angrad, IntWrapper degrees, IntWrapper minutes, DoubleWrapper seconds)
      Parameters:
      angrad - Angle in radians.
      degrees - (out) Degrees, in [0,180].
      minutes - (out) Minutes, in [0,59].
      seconds - (out) Seconds, in [0.0,60.0[.
      Returns:
      true if the resulting angle in [-180deg,180deg] is positive, false if it is negative.
    • isInClockwiseDomain

      public static boolean isInClockwiseDomain(double startAngRad, double angSpanRad, double angRad)
      NB: Since 2*Math.PI invalid input: '<' 2*PI, a span of 2*Math.PI does not mean full angular range. ex.: isInClockwiseDomain(0.0, 2*Math.PI, -1e-20) returns false. ---> For full angular range, use a span > 2*Math.PI, like 2*PI_SUP constant of this class.
      Parameters:
      startAngRad - An angle, in radians.
      angSpanRad - An angular span, >= 0.0, in radians.
      angRad - An angle, in radians.
      Returns:
      true if angRad is in the clockwise angular domain going from startAngRad, over angSpanRad, extremities included, false otherwise.
    • sinh

      public static double sinh(double value)
      Some properties of sinh(x) = (exp(x)-exp(-x))/2: 1) defined on ]-Infinity,+Infinity[ 2) result in ]-Infinity,+Infinity[ 3) sinh(x) = -sinh(-x) (implies sinh(0) = 0) 4) sinh(epsilon) ~= epsilon 5) lim(sinh(x),x->+Infinity) = +Infinity (y increasing exponentially faster than x) 6) reaches +Infinity (double overflow) for x >= 710.475860073944, i.e. a bit further than exp(x)
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic sine.
    • cosh

      public static double cosh(double value)
      Some properties of cosh(x) = (exp(x)+exp(-x))/2: 1) defined on ]-Infinity,+Infinity[ 2) result in [1,+Infinity[ 3) cosh(0) = 1 4) cosh(x) = cosh(-x) 5) lim(cosh(x),x->+Infinity) = +Infinity (y increasing exponentially faster than x) 6) reaches +Infinity (double overflow) for x >= 710.475860073944, i.e. a bit further than exp(x)
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic cosine.
    • coshm1

      public static double coshm1(double value)
      Much more accurate than cosh(value)-1, for arguments (and results) close to zero. coshm1(-0.0) = -0.0, for homogeneity with acosh1p(-0.0) = -0.0.
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic cosine, minus 1.
    • sinhAndCosh

      public static double sinhAndCosh(double value, DoubleWrapper hcosine)
      Computes hyperbolic sine and hyperbolic cosine together.
      Parameters:
      value - A double value.
      hcosine - (out) Value hyperbolic cosine.
      Returns:
      Value hyperbolic sine.
    • tanh

      public static double tanh(double value)
      Some properties of tanh(x) = sinh(x)/cosh(x) = (exp(2*x)-1)/(exp(2*x)+1): 1) defined on ]-Infinity,+Infinity[ 2) result in ]-1,1[ 3) tanh(x) = -tanh(-x) (implies tanh(0) = 0) 4) tanh(epsilon) ~= epsilon 5) lim(tanh(x),x->+Infinity) = 1 6) reaches 1 (double loss of precision) for x = 19.061547465398498
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic tangent.
    • asinh

      public static double asinh(double value)
      Some properties of asinh(x) = log(x + sqrt(x^2 + 1)) 1) defined on ]-Infinity,+Infinity[ 2) result in ]-Infinity,+Infinity[ 3) asinh(x) = -asinh(-x) (implies asinh(0) = 0) 4) asinh(epsilon) ~= epsilon 5) lim(asinh(x),x->+Infinity) = +Infinity (y increasing logarithmically slower than x)
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic arcsine.
    • acosh

      public static double acosh(double value)
      Some properties of acosh(x) = log(x + sqrt(x^2 - 1)): 1) defined on [1,+Infinity[ 2) result in ]0,+Infinity[ (by convention, since cosh(x) = cosh(-x)) 3) acosh(1) = 0 4) acosh(1+epsilon) ~= log(1 + sqrt(2*epsilon)) ~= sqrt(2*epsilon) 5) lim(acosh(x),x->+Infinity) = +Infinity (y increasing logarithmically slower than x)
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic arccosine.
    • acosh1p

      public static double acosh1p(double value)
      Much more accurate than acosh(1+value), for arguments (and results) close to zero. acosh1p(-0.0) = -0.0, for homogeneity with sqrt(-0.0) = -0.0, which looks about the same near 0.
      Parameters:
      value - A double value.
      Returns:
      Hyperbolic arccosine of (1+value).
    • atanh

      public static double atanh(double value)
      Some properties of atanh(x) = log((1+x)/(1-x))/2: 1) defined on ]-1,1[ 2) result in ]-Infinity,+Infinity[ 3) atanh(-1) = -Infinity (by continuity) 4) atanh(1) = +Infinity (by continuity) 5) atanh(epsilon) ~= epsilon 6) lim(atanh(x),x->1) = +Infinity
      Parameters:
      value - A double value.
      Returns:
      Value hyperbolic arctangent.
    • exp

      public static double exp(double value)
      Parameters:
      value - A double value.
      Returns:
      e^value.
    • expQuick

      public static double expQuick(double value)
      Quick exp, with a max relative error of about 2.94e-2 for |value| invalid input: '<' 700.0 or so, and no accuracy at all outside this range. Derived from a note by Nicol N. Schraudolph, IDSIA, 1998.
      Parameters:
      value - A double value.
      Returns:
      e^value.
    • expm1

      public static double expm1(double value)
      Much more accurate than exp(value)-1, for arguments (and results) close to zero.
      Parameters:
      value - A double value.
      Returns:
      e^value-1.
    • log

      public static double log(double value)
      Parameters:
      value - A double value.
      Returns:
      Value logarithm (base e).
    • logQuick

      public static double logQuick(double value)
      Quick log, with a max relative error of about 1.9e-3 for values in ]Double.MIN_NORMAL,+Infinity[, and worse accuracy outside this range.
      Parameters:
      value - A double value, in ]0,+Infinity[ (strictly positive and finite).
      Returns:
      Value logarithm (base e).
    • log10

      public static double log10(double value)
      Parameters:
      value - A double value.
      Returns:
      Value logarithm (base 10).
    • log1p

      public static double log1p(double value)
      Much more accurate than log(1+value), for arguments (and results) close to zero.
      Parameters:
      value - A double value.
      Returns:
      Logarithm (base e) of (1+value).
    • pow

      public static double pow(double value, double power)
      1e-13ish accuracy or better on whole double range.
      Parameters:
      value - A double value.
      power - A power.
      Returns:
      value^power.
    • powQuick

      public static double powQuick(double value, double power)
      Quick pow, with a max relative error of about 1e-2 for value >= Double.MIN_NORMAL and 1e-10 invalid input: '<' |value^power| invalid input: '<' 1e10, of about 6e-2 for value >= Double.MIN_NORMAL and 1e-40 invalid input: '<' |value^power| invalid input: '<' 1e40, and worse accuracy otherwise.
      Parameters:
      value - A double value, in ]0,+Infinity[ (strictly positive and finite).
      power - A double value.
      Returns:
      value^power.
    • powFast

      public static double powFast(double value, int power)
      This treatment is somehow accurate for low values of |power|, and for |power*getExponent(value)| invalid input: '<' 1023 or so (to stay away from double extreme magnitudes (large and small)).
      Parameters:
      value - A double value.
      power - A power.
      Returns:
      value^power.
    • pow2

      public static float pow2(float value)
      Parameters:
      value - A float value.
      Returns:
      value*value.
    • pow2

      public static double pow2(double value)
      Parameters:
      value - A double value.
      Returns:
      value*value.
    • pow3

      public static float pow3(float value)
      Parameters:
      value - A float value.
      Returns:
      value*value*value.
    • pow3

      public static double pow3(double value)
      Parameters:
      value - A double value.
      Returns:
      value*value*value.
    • sqrt

      public static double sqrt(double value)
      Parameters:
      value - A double value.
      Returns:
      Value square root.
    • sqrtQuick

      public static double sqrtQuick(double value)
      Quick sqrt, with with a max relative error of about 3.41e-2 for values in [Double.MIN_NORMAL,Double.MAX_VALUE], and worse accuracy outside this range.
      Parameters:
      value - A double value.
      Returns:
      Value square root.
    • invSqrtQuick

      public static double invSqrtQuick(double value)
      Quick inverse of square root, with a max relative error of about 3.44e-2 for values in [Double.MIN_NORMAL,Double.MAX_VALUE], and worse accuracy outside this range. This implementation uses zero step of Newton's method. Here are the max relative errors on [Double.MIN_NORMAL,Double.MAX_VALUE] depending on number of steps, if you want to copy-paste this code and use your own number: n=0: about 3.44e-2 n=1: about 1.75e-3 n=2: about 4.6e-6 n=3: about 3.17e-11 n=4: about 3.92e-16 n=5: about 3.03e-16
      Parameters:
      value - A double value.
      Returns:
      Inverse of value square root.
    • cbrt

      public static double cbrt(double value)
      Parameters:
      value - A double value.
      Returns:
      Value cubic root.
    • hypot

      public static double hypot(double x, double y)
      Returns:
      sqrt(x^2+y^2) without intermediate overflow or underflow.
    • hypot

      public static double hypot(double x, double y, double z)
      Returns:
      sqrt(x^2+y^2+z^2) without intermediate overflow or underflow.
    • floor

      public static float floor(float value)
      Parameters:
      value - A float value.
      Returns:
      Floor of value.
    • floor

      public static double floor(double value)
      Parameters:
      value - A double value.
      Returns:
      Floor of value.
    • ceil

      public static float ceil(float value)
      Parameters:
      value - A float value.
      Returns:
      Ceiling of value.
    • ceil

      public static double ceil(double value)
      Parameters:
      value - A double value.
      Returns:
      Ceiling of value.
    • round

      public static int round(float value)
      Might have different semantics than StrictMath.round(float), see bugs 6430675 and 8010430.
      Parameters:
      value - A double value.
      Returns:
      Value rounded to nearest int, choosing superior int in case two are equally close (i.e. rounding-up).
    • round

      public static long round(double value)
      Might have different semantics than StrictMath.round(double), see bugs 6430675 and 8010430.
      Parameters:
      value - A double value.
      Returns:
      Value rounded to nearest long, choosing superior long in case two are equally close (i.e. rounding-up).
    • roundEven

      public static int roundEven(float value)
      Parameters:
      value - A float value.
      Returns:
      Value rounded to nearest int, choosing even int in case two are equally close.
    • roundEven

      public static long roundEven(double value)
      Parameters:
      value - A double value.
      Returns:
      Value rounded to nearest long, choosing even long in case two are equally close.
    • rint

      public static float rint(float value)
      Parameters:
      value - A float value.
      Returns:
      The float mathematical integer closest to the specified value, choosing even one if two are equally close, or respectively NaN, +-Infinity or +-0.0f if the value is any of these.
    • rint

      public static double rint(double value)
      Parameters:
      value - A double value.
      Returns:
      The double mathematical integer closest to the specified value, choosing even one if two are equally close, or respectively NaN, +-Infinity or +-0.0 if the value is any of these.
    • floorToInt

      public static int floorToInt(double value)
      Parameters:
      value - A double value.
      Returns:
      Floor of value as int, or closest int if floor is out of int range, or 0 if value is NaN.
    • ceilToInt

      public static int ceilToInt(double value)
      Parameters:
      value - A double value.
      Returns:
      Ceiling of value as int, or closest int if ceiling is out of int range, or 0 if value is NaN.
    • roundToInt

      public static int roundToInt(double value)
      Parameters:
      value - A double value.
      Returns:
      Value rounded to nearest int, choosing superior int in case two are equally close (i.e. rounding-up).
    • roundEvenToInt

      public static int roundEvenToInt(double value)
      Parameters:
      value - A double value.
      Returns:
      Value rounded to nearest int, choosing even int in case two are equally close.
    • toRange

      public static float toRange(float min, float max, float value)
      Parameters:
      min - A float value.
      max - A float value.
      value - A float value.
      Returns:
      min if value invalid input: '<' min, max if value > max, value otherwise.
    • toRange

      public static double toRange(double min, double max, double value)
      Parameters:
      min - A double value.
      max - A double value.
      value - A double value.
      Returns:
      min if value invalid input: '<' min, max if value > max, value otherwise.
    • remainder

      public static double remainder(double dividend, double divisor)
      Returns dividend - divisor * n, where n is the mathematical integer closest to dividend/divisor. If dividend/divisor is equally close to surrounding integers, we choose n to be the integer of smallest magnitude, which makes this treatment differ from StrictMath.IEEEremainder(double,double), where n is chosen to be the even integer. Note that the choice of n is not done considering the double approximation of dividend/divisor, because it could cause result to be outside [-|divisor|/2,|divisor|/2] range. The practical effect is that if multiple results would be possible, we always choose the result that is the closest to (and has the same sign as) the dividend. Ex. : - for (-3.0,2.0), this method returns -1.0, whereas StrictMath.IEEEremainder returns 1.0. - for (-5.0,2.0), both this method and StrictMath.IEEEremainder return -1.0. If the remainder is zero, its sign is the same as the sign of the first argument. If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or negative zero, then the result is NaN. If the first argument is finite and the second argument is infinite, then the result is the same as the first argument. NB: - Modulo operator (%) returns a value in ]-|divisor|,|divisor|[, which sign is the same as dividend. - As for modulo operator, the sign of the divisor has no effect on the result. - On some architecture, % operator has been observed to return NaN for some subnormal values of divisor, when dividend exponent is 1023, which impacts the correctness of this method.
      Parameters:
      dividend - Dividend.
      divisor - Divisor.
      Returns:
      Remainder of dividend/divisor, i.e. a value in [-|divisor|/2,|divisor|/2].
    • normalizeMinusPiPi

      public static double normalizeMinusPiPi(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      The same angle, in radians, but in [-PI,PI].
    • normalizeMinusPiPiFast

      public static double normalizeMinusPiPiFast(double angle)
      Not accurate for large values.
      Parameters:
      angle - Angle in radians.
      Returns:
      The same angle, in radians, but in [-PI,PI].
    • normalizeZeroTwoPi

      public static double normalizeZeroTwoPi(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      The same angle, in radians, but in [0,2*PI].
    • normalizeZeroTwoPiFast

      public static double normalizeZeroTwoPiFast(double angle)
      Not accurate for large values.
      Parameters:
      angle - Angle in radians.
      Returns:
      The same angle, in radians, but in [0,2*PI].
    • normalizeMinusHalfPiHalfPi

      public static double normalizeMinusHalfPiHalfPi(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle value modulo PI, in radians, in [-PI/2,PI/2].
    • normalizeMinusHalfPiHalfPiFast

      public static double normalizeMinusHalfPiHalfPiFast(double angle)
      Not accurate for large values.
      Parameters:
      angle - Angle in radians.
      Returns:
      Angle value modulo PI, in radians, in [-PI/2,PI/2].
    • isNaNOrInfinite

      public static boolean isNaNOrInfinite(float value)
      Parameters:
      value - A float value.
      Returns:
      true if the specified value is NaN or +-Infinity, false otherwise.
    • isNaNOrInfinite

      public static boolean isNaNOrInfinite(double value)
      Parameters:
      value - A double value.
      Returns:
      true if the specified value is NaN or +-Infinity, false otherwise.
    • getExponent

      public static int getExponent(float value)
      Parameters:
      value - A float value.
      Returns:
      Value unbiased exponent.
    • getExponent

      public static int getExponent(double value)
      Parameters:
      value - A double value.
      Returns:
      Value unbiased exponent.
    • signum

      public static float signum(float value)
      Parameters:
      value - A float value.
      Returns:
      -1.0f if the specified value is invalid input: '<' 0, 1.0f if it is > 0, and the value itself if it is NaN or +-0.0f.
    • signum

      public static double signum(double value)
      Parameters:
      value - A double value.
      Returns:
      -1.0 if the specified value is invalid input: '<' 0, 1.0 if it is > 0, and the value itself if it is NaN or +-0.0.
    • signFromBit

      public static int signFromBit(float value)
      Parameters:
      value - A float value.
      Returns:
      -1 if sign bit is 1, 1 if sign bit is 0.
    • signFromBit

      public static long signFromBit(double value)
      Parameters:
      value - A double value.
      Returns:
      -1 if sign bit is 1, 1 if sign bit is 0.
    • copySign

      public static float copySign(float magnitude, float sign)
      A sign of NaN is interpreted as positive.
      Parameters:
      magnitude - A float value.
      sign - A float value.
      Returns:
      A value with the magnitude of the first argument, and the sign of the second argument.
    • copySign

      public static double copySign(double magnitude, double sign)
      A sign of NaN is interpreted as positive.
      Parameters:
      magnitude - A double value.
      sign - A double value.
      Returns:
      A value with the magnitude of the first argument, and the sign of the second argument.
    • ulp

      public static float ulp(float value)
      The ULP (Unit in the Last Place) is the distance to the next value larger in magnitude.
      Parameters:
      value - A float value.
      Returns:
      The size of an ulp of the specified value, or Float.MIN_VALUE if it is +-0.0f, or +Infinity if it is +-Infinity, or NaN if it is NaN.
    • ulp

      public static double ulp(double value)
      The ULP (Unit in the Last Place) is the distance to the next value larger in magnitude.
      Parameters:
      value - A double value.
      Returns:
      The size of an ulp of the specified value, or Double.MIN_VALUE if it is +-0.0, or +Infinity if it is +-Infinity, or NaN if it is NaN.
    • nextAfter

      public static float nextAfter(float start, double direction)
      If both arguments are +-0.0(f), (float)direction is returned. If both arguments are +Infinity or -Infinity, respectively +Infinity or -Infinity is returned.
      Parameters:
      start - A float value.
      direction - A double value.
      Returns:
      The float adjacent to start towards direction, considering that +(-)Float.MIN_VALUE is adjacent to +(-)0.0f, and that +(-)Float.MAX_VALUE is adjacent to +(-)Infinity, or NaN if any argument is NaN.
    • nextAfter

      public static double nextAfter(double start, double direction)
      If both arguments are +-0.0, direction is returned. If both arguments are +Infinity or -Infinity, respectively +Infinity or -Infinity is returned.
      Parameters:
      start - A double value.
      direction - A double value.
      Returns:
      The double adjacent to start towards direction, considering that +(-)Double.MIN_VALUE is adjacent to +(-)0.0, and that +(-)Double.MAX_VALUE is adjacent to +(-)Infinity, or NaN if any argument is NaN.
    • nextDown

      public static float nextDown(float start)
      Semantically equivalent to nextAfter(start,Double.NEGATIVE_INFINITY).
    • nextDown

      public static double nextDown(double start)
      Semantically equivalent to nextAfter(start,Double.NEGATIVE_INFINITY).
    • nextUp

      public static float nextUp(float start)
      Semantically equivalent to nextAfter(start,Double.POSITIVE_INFINITY).
    • nextUp

      public static double nextUp(double start)
      Semantically equivalent to nextAfter(start,Double.POSITIVE_INFINITY).
    • scalb

      public static float scalb(float value, int scaleFactor)
      Precision may be lost if the result is subnormal.
      Parameters:
      value - A float value.
      scaleFactor - An int value.
      Returns:
      value * 2^scaleFactor, or a value equivalent to the specified one if it is NaN, +-Infinity or +-0.0f.
    • scalb

      public static double scalb(double value, int scaleFactor)
      Precision may be lost if the result is subnormal.
      Parameters:
      value - A double value.
      scaleFactor - An int value.
      Returns:
      value * 2^scaleFactor, or a value equivalent to the specified one if it is NaN, +-Infinity or +-0.0.
    • abs

      public static float abs(float a)
    • abs

      public static double abs(double a)
    • min

      public static float min(float a, float b)
    • min

      public static double min(double a, double b)
    • max

      public static float max(float a, float b)
    • max

      public static double max(double a, double b)
    • IEEEremainder

      public static double IEEEremainder(double f1, double f2)
    • random

      public static double random()
    • remainderTwoPi

      private static double remainderTwoPi(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Remainder of (angle % (2*PI)), in [-PI,PI].
    • remainderPi

      private static double remainderPi(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Remainder of (angle % PI), in [-PI/2,PI/2].
    • remainderPiO2

      private static long remainderPiO2(double angle)
      Parameters:
      angle - Angle in radians.
      Returns:
      Bits of double corresponding to remainder of (angle % (PI/2)), in [-PI/4,PI/4], with quadrant encoded in exponent bits.
    • remainderTwoPiFast

      private static double remainderTwoPiFast(double angle)
      Not accurate for large values.
      Parameters:
      angle - Angle in radians.
      Returns:
      Remainder of (angle % (2*PI)), in [-PI,PI].
    • remainderPiFast

      private static double remainderPiFast(double angle)
      Not accurate for large values.
      Parameters:
      angle - Angle in radians.
      Returns:
      Remainder of (angle % PI), in [-PI/2,PI/2].