Package adams.core
Class LittleEndian
- java.lang.Object
-
- adams.core.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 Summary
Constructors Constructor Description LittleEndian()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
bytesToDouble(byte[] bytes)
Turns 8 bytes into a double.static float
bytesToFloat(byte[] bytes)
Turns 8 bytes into a float.static int
bytesToInt(byte[] bytes)
Turns 4 bytes into an int.static int
bytesToShort(byte[] bytes)
Turns 2 bytes into an int.static String
bytesToString(byte[] bytes)
Turns the bytes into a string (terminated by a NUL or end of bytes).static boolean
isBitSet(byte b, int mask)
Checks whether a certain bit is set.
-
-
-
Method Detail
-
isBitSet
public static boolean isBitSet(byte b, int mask)
Checks whether a certain bit is set.- Parameters:
b
- the byte to checkmask
- 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
-
-