java,十进制转二进制

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

public class Test {

	public static void main(String[] args) {
		System.out.println(convert(32));
	}

	private static String convert(int m) {
		List<Integer> list = new ArrayList<Integer>();
		StringBuffer sb = new StringBuffer();

		while (m / 2 != 0) {
			list.add(m % 2);
			m = m / 2;
		}
		list.add(m % 2);
		for (int i = list.size() - 1; i >= 0; i--) {
			sb.append(list.get(i));
		}

		return sb.toString();

	}

}

100000

    原文作者:进制转换
    原文地址: https://blog.csdn.net/u010002184/article/details/50985589
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞