0

Is it recommended to use Hexadecimal numbers (base 16) for ID numbers ?

For Example: Lets say i have a few objects or threads and i wanted to give them an ID and i used 0xF00D and 0xF00B

My question then is: what is the advantage of this over just using base 10 IDs like 1 and 2 ?

j2emanue
  • 60,549
  • 65
  • 286
  • 456
  • Use hex when it is more convenient to represent values as hex. I'm not sure what else there is to say on that... – Oliver Charlesworth Oct 09 '13 at 00:14
  • 1
    Hex integers perform much better and take less space than decimal integers ... NOT! If it's a numeric constant ... just use whatever notation is more readable in your code. It's as simple as that :) – paulsm4 Oct 09 '13 at 00:14
  • thanks for the hint on performance gain and space. so if i had a constant defined like public static int final aNumber=0xF00D; would it be more efficient as opposed to public static int final aNumber=3; – j2emanue Oct 09 '13 at 00:20
  • `public static int final aNumber=0xF00D;` *IS COMPLETELY EQUIVALENT* to `public static int final aNumber=3;`. *THERE IS NO DIFFERENCE*! – paulsm4 Oct 09 '13 at 00:39

0 Answers0