Package de.mhus.lib.core
Class MMath
- java.lang.Object
-
- de.mhus.lib.core.MMath
-
public class MMath extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intROTATE_LEFTstatic intROTATE_RIGHT
-
Constructor Summary
Constructors Constructor Description MMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byteaddRotate(byte b, byte add)static longpow(long a, int b)static byterotl(byte data, int distance)static introtl(int data, int distance)static byterotr(byte data, int distance)static introtr(int data, int distance)static bytesubRotate(byte b, byte add)static StringtoBasis36(long value, int digits)Pack the number in a base 36 numerical system.static StringtoBasis36WithIdent(long value, long ident, int digits)Pack the number in a base 36 numerical system.static doubletruncateDecimals(double d, int len)static intunsignetByteToInt(byte b)
-
-
-
Field Detail
-
ROTATE_LEFT
public static final int ROTATE_LEFT
- See Also:
- Constant Field Values
-
ROTATE_RIGHT
public static final int ROTATE_RIGHT
- See Also:
- Constant Field Values
-
-
Method Detail
-
toBasis36
public static String toBasis36(long value, int digits)
Pack the number in a base 36 numerical system. This means the characters 0-9 A-Z are used. This is the maximum packed system if you want to use case insensitive strings.- Parameters:
value- The value to convertdigits- number of minimum digits (expect the minus character if the value is negative)- Returns:
- encoded string
-
toBasis36WithIdent
public static String toBasis36WithIdent(long value, long ident, int digits)
Pack the number in a base 36 numerical system. This means the characters 0-9 A-Z are used. This is the maximum packed system if you want to use case insensitive strings. This function creates ids specially for logger traces.- Parameters:
value- The value to convertident- additional ident at the right side, has 4 digitsdigits- number of minimum digits (expect the minus character if the value is negative)- Returns:
- encoded string
-
truncateDecimals
public static double truncateDecimals(double d, int len)
-
pow
public static long pow(long a, int b)
-
unsignetByteToInt
public static int unsignetByteToInt(byte b)
-
rotr
public static int rotr(int data, int distance)
-
rotl
public static int rotl(int data, int distance)
-
rotr
public static byte rotr(byte data, int distance)
-
rotl
public static byte rotl(byte data, int distance)
-
addRotate
public static byte addRotate(byte b, byte add)
-
subRotate
public static byte subRotate(byte b, byte add)
-
-