/** * Extracts all the primitive types (2^n) from a given type-integer * * @param type The type-integer to extract. * @param returns The array of primitive integer types. */ public static int[] getTypes(int type) { // System.out.println("To Type: "+type); if (type == 0) return new int[0]; int log = (int) Math.floor(Math.log(type) / Math.log(2)); // System.out.println("Log: "+log); int checktype = (int) Math.pow(2, log); int[] types = new int[log + 1]; int c = 0; for (; type > 0; checktype /= 2) { // System.out.println("Checktype = "+checktype); if (checktype > type) continue; types[c] = checktype; type -= checktype; c++; } return (int[]) Arrayutils.cropArray(types, c); }