I was looking over this code to calculate math.sqrt in Java. Why did they use hex values in some of the loops and normal values for variables? What benefits are there to use hex?
I was looking over this code to calculate math.sqrt in Java. Why did they
Share
Because hex corresponds much more closely to bits that decimal numbers. Each hex digit corresponds to 4 bits (a nibble). So, once you’ve learned the bitmask associated with each hex digit (0-F), you can do something like ‘I want a mask for the low order byte’:
or, ‘I want a mask for the bottom 31 bits’:
Just for reference: