Return to Snippet

Revision: 4545
at January 4, 2008 01:04 by javapda


Updated Code
int[] getIntBytesFromInt(int base) {
  int[] nums = new int[4];
  nums[0] = base & 0x000000FF;
  nums[1] = (base>>>8) & 0x000000FF;
  nums[2] = (base>>>16) & 0x000000FF;
  nums[3] = (base>>>24) & 0x000000FF;
  return nums;
}

Revision: 4544
at January 3, 2008 23:06 by javapda


Initial Code
int[] getIntBytesFromInt(int base) {
  int[] nums = new int[4];
  nums[0] = base & 0x0000000F;
  nums[1] = (base>>>8) & 0x0000000F;
  nums[2] = (base>>>16) & 0x0000000F;
  nums[3] = (base>>>24) & 0x0000000F;
  return nums;
}

Initial URL

                                

Initial Description
in Java an int is 4 bytes (32 bits)

Initial Title
Convert int to int array of the byte data

Initial Tags

                                

Initial Language
Java