Android Utililty Methods Big Endian Convert

List of utility methods to do Big Endian Convert

Description

The list of methods to do Big Endian Convert are organized into topic(s).

Method

byte[]charAsBigEnd(byte[] a, int i, char v)
Convert a char value into an array in big-endian format, copying the result in the passed array at the point especified.
a[i + 0] = (byte) (0xFF & (v >> 8));
a[i + 1] = (byte) (0xFF & v);
return a;
byte[]charAsBigEnd(char val)
Convert a char value into an array in big-endian format.
byte[] array = new byte[2];
return charAsBigEnd(array, 0, val);
byte[]intAsBigEnd(byte[] a, int i, int v)
Convert an int value into an array in big-endian format, copying the result in the passed array at the point especified.
a[i + 0] = (byte) (0xFF & (v >> 24));
a[i + 1] = (byte) (0xFF & (v >> 16));
a[i + 2] = (byte) (0xFF & (v >> 8));
a[i + 3] = (byte) (0xFF & v);
return a;
byte[]intAsBigEnd(int val)
Convert an int value into an array in big-endian format.
byte[] array = new byte[4];
return intAsBigEnd(array, 0, val);
byte[]longAsBigEnd(byte[] a, int i, long v)
Convert a long value into an array in big-endian format, copying the result in the passed array at the point especified.
a[i + 0] = (byte) (0xFF & (v >> 56));
a[i + 1] = (byte) (0xFF & (v >> 48));
a[i + 2] = (byte) (0xFF & (v >> 40));
a[i + 3] = (byte) (0xFF & (v >> 32));
a[i + 4] = (byte) (0xFF & (v >> 24));
a[i + 5] = (byte) (0xFF & (v >> 16));
a[i + 6] = (byte) (0xFF & (v >> 8));
a[i + 7] = (byte) (0xFF & v);
...
byte[]longAsBigEnd(long val)
Convert a long value into an array in big-endian format.
byte[] array = new byte[8];
return longAsBigEnd(array, 0, val);
byte[]shortAsBigEnd(byte[] a, int i, short v)
Convert a short value into an array in big-endian format, copying the result in the passed array at the point especified.
a[i + 0] = (byte) (0xFF & (v >> 8));
a[i + 1] = (byte) (0xFF & v);
return a;
byte[]shortAsBigEnd(short val)
Convert a short value into an array in big-endian format.
byte[] array = new byte[2];
return shortAsBigEnd(array, 0, val);
voidtoBigEndianByteArray(int val, byte[] b, int pos)
to Big Endian Byte Array
assert (pos + 4 <= b.length);
for (int i = 3; i >= 0; i--) {
    b[pos + i] = (byte) (val & 0x000000FF);
    val = val >> 8;
voidtoBigEndianByteArray(long val, byte[] b, int pos)
to Big Endian Byte Array
assert (pos + 8 <= b.length);
for (int i = 7; i >= 0; i--) {
    b[pos + i] = (byte) (val & 0x00000000000000FFl);
    val = val >> 8;