Class BitManipulation


  • public class BitManipulation
    extends Object
    • Constructor Detail

      • BitManipulation

        public BitManipulation()
    • Method Detail

      • setBitValue

        public static byte setBitValue​(byte value,
                                       int bitNumber,
                                       boolean on)
      • getBitMask

        public static byte getBitMask​(int bitNumber)
      • getBitMask

        public static byte getBitMask​(int... bitNumbers)
      • isBitSet

        public static boolean isBitSet​(byte value,
                                       int bitNumber)
      • updateWithMaskedData

        public static byte updateWithMaskedData​(byte value,
                                                short mask,
                                                byte data,
                                                int dataShift)
      • updateValueWithMaskedData

        public static byte updateValueWithMaskedData​(byte value,
                                                     short mask,
                                                     byte data)
        Update only the bits as specified by mask with the specified bits; the value of all other bits are preserved. Note: mask is a short to ensure unsigned behaviour.
        Parameters:
        value - the value to update
        mask - a bit mask with 1s specifying the bits to update
        data - the new bits to apply to the value
        Returns:
        the updated value
      • bytesToWord

        public static int bytesToWord​(int msb,
                                      int lsb,
                                      boolean isSigned)
      • reverseByte

        public static byte reverseByte​(byte value)
      • reverseShort

        public static short reverseShort​(short value)