Brooklyn

brooklyn.util.math
[Java] Class BitUtils

java.lang.Object
  brooklyn.util.math.BitUtils

public class BitUtils

Method Summary
static byte reverseBitSignificance(byte b)

reverses the bits in a byte, i.e. 128 = 0b1000000 = bit list {0,0,0,0,0,0,0,1}, reversed yields 1 = 0b00000001 = bit list {1,0,0,0,0,0,0,0}

static byte[] reverseBitSignificance(byte... bytes)

returns an array of bytes where the bits in each byte have been reversed; note however the order of the arguments is not reversed; useful e.g. in working with IP address CIDR's

static byte reverseBitSignificanceInByte(int b)

as reverseBitSignificance(byte) but accepting int for convenience

static byte[] reverseBitSignificanceInBytes(int... bytes)

as reverseBitSignificance(byte...), but taking ints for convenience (ignoring high bits)

static int unsigned(byte b)

why oh why are bytes signed!

static int unsignedByte(int b)

returns the value in 0..255 which is equivalent mod 256

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

reverseBitSignificance

public static byte reverseBitSignificance(byte b)
reverses the bits in a byte, i.e. 128 = 0b1000000 = bit list {0,0,0,0,0,0,0,1}, reversed yields 1 = 0b00000001 = bit list {1,0,0,0,0,0,0,0}


reverseBitSignificance

public static byte[] reverseBitSignificance(byte... bytes)
returns an array of bytes where the bits in each byte have been reversed; note however the order of the arguments is not reversed; useful e.g. in working with IP address CIDR's


reverseBitSignificanceInByte

public static byte reverseBitSignificanceInByte(int b)
as reverseBitSignificance(byte) but accepting int for convenience


reverseBitSignificanceInBytes

public static byte[] reverseBitSignificanceInBytes(int... bytes)
as reverseBitSignificance(byte...), but taking ints for convenience (ignoring high bits)


unsigned

public static int unsigned(byte b)
why oh why are bytes signed!


unsignedByte

public static int unsignedByte(int b)
returns the value in 0..255 which is equivalent mod 256


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.