/**
 * 
 */
package com.shanlin.demo.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shanlin
 *
 */
public class BinaryUtil {
	public static final int type0 = 0x0001;
	public static final int type1 = 0x0002;
	public static final int type2 = 0x0004;
	public static final int type3 = 0x0008;
	public static final int type4 = 0x0010;
	public static final int type5 = 0x0020;
	public static final int type6 = 0x0040;
	public static final int type7 = 0x0080;
	public static final int type8 = 0x0100;
	
	public static List<Integer> getCombination(int mix){
		List<Integer> list = new ArrayList<Integer>();
		String bin = Integer.toBinaryString(mix);
		
		char c;
		char[]  bins = bin.toCharArray();
		System.out.println(bin);
		for (int i = 0; i <bins.length; i++) {
			c = bins[i];
			if (c == '1') {
				list.add(2<<(bins.length-i-2));
			}
		}
		
		return list;
	}
	
	public static void main(String[] args) {
		System.out.println(getCombination(type1|type7|type8));
	}
}

@@ -884,16 +884,622 @@
 t;%0A%09%7D%0A%09%0A
+%09%09private BinaryUtil()%7B%0A%09%09%0A%09%7D%0A%09/**%0A%09 * %E6%8B%86%E5%88%86%EF%BC%8C%E5%A6%82%EF%BC%9A26=16+8+2%0A%09 * %0A%09 * @param target %E5%A4%A7%E4%BA%8E0%E7%9A%84%E6%95%B4%E6%95%B0%0A%09 * @return%0A%09 */%0A%09public static List%3CInteger%3E split(int target)%7B%0A%09%09Assert.isTrue(target%3E0);%0A%09%09%0A%09%09return getNext(new ArrayList%3CInteger%3E(), target, 0);%0A%09%7D%0A%09/**%0A%09 * %E8%BD%AC%E6%8D%A2%0A%09 * %0A%09 * @param list%0A%09 * @param target%0A%09 * @param pos%0A%09 * @return%0A%09 */%0A%09private static List%3CInteger%3E getNext(List%3CInteger%3E list,int target,int pos)%7B%0A%09%09int quotient = target/2;%0A%09%09int modulo = target%252;%0A%09%09%0A%09%09if (modulo == 1) %7B%0A%09%09%09list.add((int)Math.pow(2, pos));%0A%09%09%7D%0A%09%09%0A%09%09if (quotient != 0) %7B%0A%09%09%09list=getNext(list,quotient, ++pos);%0A%09%09%7D%0A%09%09%0A%09%09return list;%0A%09%7D%0A%09%0A
 %09public 

update binaryUtil