How do you define an integer as a hexadecimal number in Java? I heard something about just putting "0x" before it, but...does it stay in hexadecimal once you define it as such? And how do you set preference for lowercase/capital letters? (For example, can you make sure that 0xB7 always shows up as "B7", never "b7"?)
Like...say I simply wanted to print out a table of the hexadecimal numbers 00-1F.
for(int hexVar = ?1?, hexVar <= ?2?, hexVar++)
{
System.out.print("$" + ?3? + ",");
if (hexVar % 8 = 7)
System.out.print(\n);
}
The define I labeled as "?1?" would be the starting hexadecimal value of the variable, "?2?" would be 32 or 0x20 written however, and ?3? would be the hexadecimal value with no signs or extra symbols or any kind. How would I write these? Or...say I wanted to convert a number from decimal to hexadecimal and back again. What subroutine, function, whatever, would I use? In fact, am I even supposed to define it as a normal integer, or are hexadecimal numbers a class like strings are?
----------------
I'm working on a hack! Check it out here. Progress: 64/95 levels.
Like...say I simply wanted to print out a table of the hexadecimal numbers 00-1F.
for(int hexVar = ?1?, hexVar <= ?2?, hexVar++)
{
System.out.print("$" + ?3? + ",");
if (hexVar % 8 = 7)
System.out.print(\n);
}
The define I labeled as "?1?" would be the starting hexadecimal value of the variable, "?2?" would be 32 or 0x20 written however, and ?3? would be the hexadecimal value with no signs or extra symbols or any kind. How would I write these? Or...say I wanted to convert a number from decimal to hexadecimal and back again. What subroutine, function, whatever, would I use? In fact, am I even supposed to define it as a normal integer, or are hexadecimal numbers a class like strings are?
----------------
I'm working on a hack! Check it out here. Progress: 64/95 levels.