Class MathUtils

java.lang.Object
com.burchard36.api.utils.MathUtils

public class MathUtils extends Object
THIS CLASS WAS PROVIDED BY ANOTHER DEVELOPER NOT ME! These math methods are faster to work with than typical Math classes, as they work with raw bits Users GitHub who provided these methods: https://github.com/frostalf
Since:
2.1.5
Author:
frostalf
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    add​(int n1, int n2)
    Efficiently adds two numbers via bit flipping
    static long
    calcExponent​(int a, int b)
    Calculated the when its exponent is
    static boolean
    isOdd​(int n)
    Efficiently calculates if a provided Integer is odd
    static int
    multiply​(int n1, int n2)
    Efficiently multiplies 2 numbers via bit flipping
    static short
    squareRoot​(short num)
    Bit-flips a square root of an Short

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MathUtils

      public MathUtils()
  • Method Details

    • multiply

      public static int multiply(int n1, int n2)
      Efficiently multiplies 2 numbers via bit flipping
      Parameters:
      n1 - A Integer
      n2 - A Integer
      Returns:
      The result Integer of *
      Since:
      2.1.5
    • add

      public static int add(int n1, int n2)
      Efficiently adds two numbers via bit flipping
      Parameters:
      n1 - A Integer
      n2 - A Integer
      Returns:
      The result Integer of +
      Since:
      2.1.5
    • squareRoot

      public static short squareRoot(short num)
      Bit-flips a square root of an Short
      Parameters:
      num - A Short to calculate square root of
      Returns:
      The square root of
      Since:
      2.1.5
    • isOdd

      public static boolean isOdd(int n)
      Efficiently calculates if a provided Integer is odd
      Parameters:
      n - A Integer to check if odd
      Returns:
      A Boolean, true if number is odd, false if not
      Since:
      2.1.5
    • calcExponent

      public static long calcExponent(int a, int b)
      Calculated the when its exponent is
      Parameters:
      a - A Integer, this is the base number
      b - A Integer, this is the exponent
      Returns:
      A Long, this is the result of this statement
      Since:
      2.1.5