10進数2桁の数値を16進数に変換

static String hex(int dec) {
	String str = "0123456789ABCDEF";
	int hex2 = dec % 16;
	int hex1 = (dec - hex2) / 16;
	
	return str.substring(hex1, hex1 + 1) + str.substring(hex2, hex2 + 1);
}

タグ:

+ タグ編集
  • タグ:
最終更新:2007年11月08日 16:54