JJ プログラム仙人修行日誌

2024/04/20 からは、プログラム仙人修行の日誌を書いてます。

16進数表示


class xDrvDspHex {
public static void main(String[] args) {

xDspHex(255);
}

static void xDspHex(int x){
int xomomi = 16*16*16;
int d;
boolean xisDsp = false;
do {
d = x / xomomi;
if (!xisDsp && (d>1)) {
xisDsp = true;
}
if (xisDsp) {
if (d ==10) System.out.print('A');
else if (d==11) System.out.print('B');
else if (d==12) System.out.print('C');
else if (d==13) System.out.print('D');
else if (d==14) System.out.print('E');
else if (d==15) System.out.print('F');
else System.out.print(d);
}
x = x % xomomi;
xomomi = xomomi / 16;
}while(xomomi > 0);
}
}