[New] New ByteHelper.reverse()

This commit is contained in:
Robert von Burg 2017-07-14 15:33:24 +02:00
parent 5640df965a
commit 0b62acc4f3
1 changed files with 10 additions and 0 deletions

View File

@ -224,6 +224,16 @@ public class ByteHelper {
return new byte[] { low, high };
}
public static byte reverse(byte x) {
byte b = 0;
for (int i = 0; i < 8; ++i) {
b <<= 1;
b |= (x & 1);
x >>= 1;
}
return b;
}
/**
* Formats the given byte array to a binary string, separating each byte by a space
*