Class NumberMath

java.lang.Object
io.github.syst3ms.skriptparser.util.math.NumberMath

public class NumberMath extends Object
Utilities for various math operations using the generic Number type I do not claim ownership of this code, it is the intellectual property of @obermuhlner.
  • Constructor Details

    • NumberMath

      public NumberMath()
  • Method Details

    • abs

      public static Number abs(Number n)
    • negate

      public static Number negate(Number n)
    • sqrt

      public static Number sqrt(Number n)
    • ln

      public static Number ln(Number n)
    • log

      public static Number log(Number base, Number n)
    • factorial

      public static Number factorial(Number n)
    • floor

      public static Number floor(Number n)
    • ceil

      public static Number ceil(Number n)
    • round

      public static Number round(Number n)
    • sin

      public static Number sin(Number n)
    • cos

      public static Number cos(Number n)
    • tan

      public static Number tan(Number n)
    • asin

      public static Number asin(Number n)
    • acos

      public static Number acos(Number n)
    • atan

      public static Number atan(Number n)
    • sinh

      public static Number sinh(Number n)
    • cosh

      public static Number cosh(Number n)
    • tanh

      public static Number tanh(Number n)
    • isPrime

      public static boolean isPrime(BigInteger number)
      Checks if a given BigInteger is prime. The certainty of this check is always 100%
      Parameters:
      number - the number to check
      Returns:
      whether or not this number is a prime
    • random

      public static Number random(Number lower, Number upper, boolean inclusive, ThreadLocalRandom random)
      Computes a random number between the two given bounds The return type is related to the parameter types in the following way :
      • Two bounds of the same type will return a result of the same type
      • If one of the bounds is a BigDecimal, so will be the result
      • If one of the bounds is a BigInteger and the other is a Double, the result will be a BigDecimal
      • If one of the bounds is a BigInteger and the other is a Long, the result will be a BigInteger
      • Otherwise (i.e one of the bounds is a long and the other a double), the result will be a double
      Parameters:
      lower - the lower bound
      upper - the upper bound
      inclusive - whether the bounds are exclusive or not (skript-parser defaults to true in its implementation)
      random - the ThreadLocalRandom instance used
      Returns:
      a random Number between the two given bounds
    • randomBigInteger

      public static BigInteger randomBigInteger(BigInteger lower, BigInteger upper, ThreadLocalRandom random)
      Parameters:
      lower - the lower bound
      upper - the upper bound
      Returns:
      a random BigInteger between lower (inclusive) and upper (exclusive)
    • randomBigDecimal

      public static BigDecimal randomBigDecimal(BigDecimal lower, BigDecimal upper, ThreadLocalRandom random)
      Parameters:
      lower - the lower bound
      upper - the upper bound
      Returns:
      a random BigDecimal between lower (inclusive) and upper (exclusive)
    • getCachedPrimes

      public static ArrayList<Integer> getCachedPrimes()