求7进制转化成2进制的java程序代码

[复制链接]
查看11 | 回复3 | 2010-12-30 15:30:38 | 显示全部楼层 |阅读模式
public class NotationConvert { private static final String[] letters = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "g", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }; public static String TentoN(int value, int number) {
if (n
回复

使用道具 举报

千问 | 2010-12-30 15:30:38 | 显示全部楼层
/*** 传进去一个7进制的字符串* * @param str* @throws Exception 如果传进去是不合理的字符串, 如8,18,ABC13之类的会报错*/ public static String test(String str) throws Exception {try { in
回复

使用道具 举报

千问 | 2010-12-30 15:30:38 | 显示全部楼层
你可以先把二进制转换成十进制 :int a=Integer.valueOf("0101",2).toString();然后再把十进制转换成十六进制 :Integer.toHexString(a);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行