// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class ByteFun {
    public static byte[] int2bytesWithComp(int v) {
        byte[] res = new byte[8];
        res[0] = (byte) v;
        res[1] = (byte) ~res[0];
        res[2] = (byte) (v >> 8);
        res[3] = (byte) ~res[2];
        res[4] = (byte) (v >> 16);
        res[5] = (byte) ~res[4];
        res[6] = (byte) (v >> 24);
        res[7] = (byte) ~res[6];
        return res;
    }
    public static void main(String[] args) {
        int v = 100000;
        byte[] ba = int2bytesWithComp(v);
        for(byte b : ba) {
            System.out.print(" " + Integer.toHexString(b >> 4 & 0x0F) + Integer.toHexString(b & 0x0F));
        }
        System.out.println();
    }
}
