Package com.burchard36.api.utils
Class MathUtils
java.lang.Object
com.burchard36.api.utils.MathUtils
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic int
add(int n1, int n2)
Efficiently adds two numbers via bit flippingstatic long
calcExponent(int a, int b)
Calculated the when its exponent isstatic boolean
isOdd(int n)
Efficiently calculates if a providedInteger
is oddstatic int
multiply(int n1, int n2)
Efficiently multiplies 2 numbers via bit flippingstatic short
squareRoot(short num)
Bit-flips a square root of anShort
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
Method Details
-
multiply
public static int multiply(int n1, int n2)Efficiently multiplies 2 numbers via bit flipping -
add
public static int add(int n1, int n2)Efficiently adds two numbers via bit flipping -
squareRoot
public static short squareRoot(short num)Bit-flips a square root of anShort
- Parameters:
num
- AShort
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 providedInteger
is odd -
calcExponent
public static long calcExponent(int a, int b)Calculated the when its exponent is
-