Here you can find the source of fromInt(final int value, final int length)
public static boolean[] fromInt(final int value, final int length)
//package com.java2s; public class Main { public static boolean[] fromInt(final int value, final int length) { boolean[] result = new boolean[length]; final boolean isNegative = (value < 0); int divResult = isNegative ? -value : value; int index = length - 1; // Calc value while (divResult > 0) { final int remains = divResult % 2; result[index--] = (remains == 1); divResult /= 2;//from www . ja v a2s.c o m } if (isNegative) { result = invert(result); result = inc(result); } return result; } private static boolean[] invert(boolean[] result) { for (int i = 0; i < result.length; i++) result[i] = !result[i]; return result; } public static boolean[] inc(boolean[] input) { boolean[] result = new boolean[input.length]; // boolean flag = input[input.length-1]; boolean add = true; for (int i = input.length - 1; i >= 0; i--) { result[i] = input[i] ^ add; // XOR add = input[i] && add; } return result; } }