public class DtoH {
public static void main(String[] args) {
toHex(60);
}
public static void toHex(int num) {
for(int x=0; x<8; x++) {
int temp = num & 15;
if(temp>9)
System.out.println((char)(temp-10+'A')); //????
else
System.out.println(temp);
num = num >>> 4;
}
}
}
The above is a small hexadecimal decimal conversion program to convert decimal number 60 this hex .
which
temp-10+'A'This code is what does that mean ?
I know the output is hexadecimal 'C', but would like to ask what this code relates to knowledge ?
Is 10 hex is 'A', 2 + 'A' is equal to 'C' of ?
------ Solution ---------------------------------------- ----
the 10,11,12,13,14,15 respective output into a, B, C, D, E, F
------ Solution ------- -------------------------------------
char t = 2 + 'A';
t = 'C';
2 + 'A' = 67
------ Solution ---------------------- ----------------------
different data types involved in computing , the data type to be cast , the direction of conversion
(unsigned) char, (unsigned) short-> int-> unsigned-> long-> unsigned long-> float-> double
------ For reference only ---------------------------------- -----
About 2 + 'A' = 'C';
I still have a question , is not the same type of how it can be simple addition
------ For reference only ---------------- -----------------------
Oh, so detailed ah , thank you
没有评论:
发表评论