Package ghidra.util
Class Conv
- java.lang.Object
-
- ghidra.util.Conv
-
public class Conv extends java.lang.Object
Helper methods for converting between number data types without negative promotion.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BYTE_MASK
A byte mask.static long
INT_MASK
An integer mask.static int
SHORT_MASK
A short mask.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
byteToInt(byte b)
Converts a byte to an integer.static long
byteToLong(byte b)
Converts a byte to a long.static short
byteToShort(byte b)
Converts a byte to a short.static long
intToLong(int i)
Converts an integer to a long.static void
main(java.lang.String[] args)
static int
shortToInt(short s)
Converts a short to an integer.static long
shortToLong(short s)
Converts a short to a long.static java.lang.String
toHexString(byte b)
Converts a byte into a padded hex string.static java.lang.String
toHexString(int i)
Converts an integer into a padded hex string.static java.lang.String
toHexString(long l)
Converts a long into a padded hex string.static java.lang.String
toHexString(short s)
Converts a short into a padded hex string.static java.lang.String
toString(byte[] array)
static java.lang.String
zeropad(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)
-
-