Package adams.core

Class LittleEndian


  • public class LittleEndian
    extends Object
    Helper class for conversions related to Little-Endian.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • LittleEndian

        public LittleEndian()
    • Method Detail

      • isBitSet

        public static boolean isBitSet​(byte b,
                                       int mask)
        Checks whether a certain bit is set.
        Parameters:
        b - the byte to check
        mask - the mask to use
      • bytesToShort

        public static int bytesToShort​(byte[] bytes)
        Turns 2 bytes into an int.
        Parameters:
        bytes - the bytes to convert
        Returns:
        the int value
      • bytesToInt

        public static int bytesToInt​(byte[] bytes)
        Turns 4 bytes into an int.
        Parameters:
        bytes - the bytes to convert
        Returns:
        the int value
      • bytesToFloat

        public static float bytesToFloat​(byte[] bytes)
        Turns 8 bytes into a float.
        Parameters:
        bytes - the bytes to convert
        Returns:
        the float value
      • bytesToDouble

        public static double bytesToDouble​(byte[] bytes)
        Turns 8 bytes into a double.
        Parameters:
        bytes - the bytes to convert
        Returns:
        the double value
      • bytesToString

        public static String bytesToString​(byte[] bytes)
        Turns the bytes into a string (terminated by a NUL or end of bytes).
        Parameters:
        bytes - the bytes to convert
        Returns:
        the string value