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 intadd(int n1, int n2)Efficiently adds two numbers via bit flippingstatic longcalcExponent(int a, int b)Calculated the when its exponent isstatic booleanisOdd(int n)Efficiently calculates if a providedIntegeris oddstatic intmultiply(int n1, int n2)Efficiently multiplies 2 numbers via bit flippingstatic shortsquareRoot(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- AShortto calculate square root of- Returns:
- The square root of
- Since:
- 2.1.5
-
isOdd
public static boolean isOdd(int n)Efficiently calculates if a providedIntegeris odd -
calcExponent
public static long calcExponent(int a, int b)Calculated the when its exponent is
-