Java Integer Convert To fromInt(int value, byte[] arr, int offset)

Here you can find the source of fromInt(int value, byte[] arr, int offset)

Description

from Int

License

Apache License

Declaration

public static void fromInt(int value, byte[] arr, int offset) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] fromInt(int value) {
        byte[] arr = new byte[4];
        fromInt(value, arr, 0);//from  w  ww.j a v  a2s  .c o m
        return arr;
    }

    public static void fromInt(int value, byte[] arr, int offset) {
        value ^= 1 << 31;//toggling highest bit
        arr[offset] = (byte) (value >>> 24);
        arr[offset + 1] = (byte) (value >>> 16);
        arr[offset + 2] = (byte) (value >>> 8);
        arr[offset + 3] = (byte) value;
    }
}

Related

  1. fromInt(int intValue)
  2. fromInt(int key)
  3. fromInt(int value)
  4. fromInt(int value)
  5. fromInt(int value)
  6. fromInt(int x, int size)
  7. fromInteger(int idx, Class clazz)
  8. fromInteger(int value)
  9. fromInteger(Integer value)