Posted By

javapda on 01/03/08


Tagged


Versions (?)

Convert int to int array of the byte data


 / Published in: Java
 

in Java an int is 4 bytes (32 bits)

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

Report this snippet  

You need to login to post a comment.