Package ghidra.util
Class Conv
- java.lang.Object
-
- ghidra.util.Conv
-
public class Conv extends java.lang.ObjectHelper methods for converting between number data types without negative promotion.
-
-
Field Summary
Fields Modifier and Type Field Description static intBYTE_MASKA byte mask.static longINT_MASKAn integer mask.static intSHORT_MASKA short mask.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbyteToInt(byte b)Converts a byte to an integer.static longbyteToLong(byte b)Converts a byte to a long.static shortbyteToShort(byte b)Converts a byte to a short.static longintToLong(int i)Converts an integer to a long.static voidmain(java.lang.String[] args)static intshortToInt(short s)Converts a short to an integer.static longshortToLong(short s)Converts a short to a long.static java.lang.StringtoHexString(byte b)Converts a byte into a padded hex string.static java.lang.StringtoHexString(int i)Converts an integer into a padded hex string.static java.lang.StringtoHexString(long l)Converts a long into a padded hex string.static java.lang.StringtoHexString(short s)Converts a short into a padded hex string.static java.lang.StringtoString(byte[] array)static java.lang.Stringzeropad(java.lang.String s, int len)Returns a string that is extended to length len with zeroes.
-
-
-
Field Detail
-
BYTE_MASK
public static final int BYTE_MASK
A byte mask.- See Also:
- Constant Field Values
-
SHORT_MASK
public static final int SHORT_MASK
A short mask.- See Also:
- Constant Field Values
-
INT_MASK
public static final long INT_MASK
An integer mask.- See Also:
- Constant Field Values
-
-
Method Detail
-
byteToShort
public static short byteToShort(byte b)
Converts a byte to a short.- Parameters:
b- the byte- Returns:
- the short equivalent of the byte
-
byteToInt
public static int byteToInt(byte b)
Converts a byte to an integer.- Parameters:
b- the byte- Returns:
- the integer equivalent of the byte
-
byteToLong
public static long byteToLong(byte b)
Converts a byte to a long.- Parameters:
b- the byte- Returns:
- the long equivalent of the byte
-
shortToInt
public static int shortToInt(short s)
Converts a short to an integer.- Parameters:
s- the short- Returns:
- the integer equivalent of the short
-
shortToLong
public static long shortToLong(short s)
Converts a short to a long.- Parameters:
s- the short- Returns:
- the long eqivalent of the short
-
intToLong
public static long intToLong(int i)
Converts an integer to a long.- Parameters:
i- the integer- Returns:
- the long equivalent of the long
-
toString
public static java.lang.String toString(byte[] array)
-
toHexString
public static java.lang.String toHexString(byte b)
Converts a byte into a padded hex string.- Parameters:
b- the byte- Returns:
- the padded hex string
-
toHexString
public static java.lang.String toHexString(short s)
Converts a short into a padded hex string.- Parameters:
s- the short- Returns:
- the padded hex string
-
toHexString
public static java.lang.String toHexString(int i)
Converts an integer into a padded hex string.- Parameters:
i- the integer- Returns:
- the padded hex string
-
toHexString
public static java.lang.String toHexString(long l)
Converts a long into a padded hex string.- Parameters:
l- the long- Returns:
- the padded hex string
-
zeropad
public static java.lang.String zeropad(java.lang.String s, int len)Returns a string that is extended to length len with zeroes.- Parameters:
s- The string to padlen- The length of the return string- Returns:
- A string that has been padded to be of legnth len
-
main
public static void main(java.lang.String[] args)
-
-