Package ghidra.util

Class Conv

java.lang.Object
ghidra.util.Conv

public class Conv extends Object
Helper methods for converting between number data types without negative promotion.

Consider using java built-in methods for conversion instead of methods from this class.

  • Field Details

  • Method Details

    • byteToShort

      @Deprecated(forRemoval=true, since="10.2") public static short byteToShort(byte b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use other built-ins like Byte.toUnsignedInt(byte)
      Parameters:
      b - the byte
      Returns:
      the short equivalent of the byte
    • byteToInt

      @Deprecated(forRemoval=true, since="10.2") public static int byteToInt(byte b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts a byte to an integer.
      Parameters:
      b - the byte
      Returns:
      the integer equivalent of the byte
    • byteToLong

      @Deprecated(forRemoval=true, since="10.2") public static long byteToLong(byte b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts a byte to a long.
      Parameters:
      b - the byte
      Returns:
      the long equivalent of the byte
    • shortToInt

      @Deprecated(forRemoval=true, since="10.2") public static int shortToInt(short s)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts a short to an integer.
      Parameters:
      s - the short
      Returns:
      the integer equivalent of the short
    • shortToLong

      @Deprecated(forRemoval=true, since="10.2") public static long shortToLong(short s)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts a short to a long.
      Parameters:
      s - the short
      Returns:
      the long eqivalent of the short
    • intToLong

      @Deprecated(forRemoval=true, since="10.2") public static long intToLong(int i)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts an integer to a long.
      Parameters:
      i - the integer
      Returns:
      the long equivalent of the long
    • toString

      @Deprecated(forRemoval=true, since="10.2") public static String toString(byte[] array)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Old and incorrect way to convert bytes to a String by casting their values to chars. Do not use. Does not seem to be used in current codebase.

      Parameters:
      array -
      Returns:
    • toHexString

      public static String toHexString(byte b)
      Consider using String.format("%02x", b) instead.

      Converts a byte into a padded hex string.

      Parameters:
      b - the byte
      Returns:
      the padded hex string
    • toHexString

      public static String toHexString(short s)
      Consider using String.format("%04x", s) instead.

      Converts a short into a padded hex string.

      Parameters:
      s - the short
      Returns:
      the padded hex string
    • toHexString

      public static String toHexString(int i)
      Consider using String.format("%08x", i) instead.

      Converts an integer into a padded hex string.

      Parameters:
      i - the integer
      Returns:
      the padded hex string
    • toHexString

      public static String toHexString(long l)
      Consider using String.format("%016x", l) instead.

      Converts a long into a padded hex string.

      Parameters:
      l - the long
      Returns:
      the padded hex string
    • zeropad

      public static String zeropad(String s, int len)
      Returns a string that is extended to length len with zeroes.
      Parameters:
      s - The string to pad
      len - The length of the return string
      Returns:
      A string that has been left-padded with zeros to be of length len