Leading zeros and numbers of hashes before arriving to solution Had been reading a post written by Adam Back a couple years back (no pun intended) with regards to calculating bitcoin difficulty in bits (so we could arrive to the number of hashes roughly needed before a solution to a block is found).

The equation being log2(difficulty)+32.

Link: https://bitcointalk.org/index.php?topic=192886.0

From his post I also understood we could also find the difficulty in bits via the block hash in hex, i.e. each leading zero * 4, then check the next hex char with the following rule: >7=+0bits, >3=+1bit, >1=+2bits, 1=+3bits.

Question being:


What is the intuition to Adam's elaboration of >7=+0bits, >3=+1bit, >1=+2bits, 1=+3bits? Maybe there is something with regards to hex conversion that I need to catch up on?
With log2(difficulty)+32, we could arrive to a fractional bit (e.g. 54.8713). Would it be possible to derive the same fractional bit given the leading block hash values, or are we at best left with an approximation?


Thanks in advance!
Look at these numbers in binary.  A hex digit is 4 bits, so 7 in hex is 0111 binary, 3 is 0011, 1 is 0001.  You can see that 7 is the largest hex digit in which the most significant bit is 0; 3 is the largest hex digit in which the two most significant bits are 0; and so on.
Yes, you can get this same value by taking the log2 of the hash value and subtracting from 256 (which is the total number of bits in the hash).  Note that the number of leading zero bits of the hash (including "fractional bits") is required to be less than or equal to the target difficulty, but in general is much more likely to be less.