So is the adjustment, I guess basically what amounts to a max value the hash can be, more granular than just adding another zero? Like instead of an increased difficulty changing it needing to start with "0000" to "00000" it goes from "0000" to "00005" or whatever on an increased difficulty adjustment? I feel like this wasn't actually answered yet in this discussion. And how does the calculated difficulty (expected time / actual time) play into this...I'm assuming that difficulty adjustment factor is just multiplied to the previous max allowable hash value to get an increase or decrease in difficulty. The way this is always described - "add a zero to increase difficulty" - clearly isn't the way it actual works so if someone could clear this up that'd be great.
Difficulty is just a representation of the target. Each block header has a target and it is represent in bits. The current target is 170da8a1 or 0000000000000000000da8a10000000000000000000000000000000000000000 in hexadecimal. For a block to be valid, the hash of the block header must be lower than or equals to the current target. For the current difficulty, you'll just use the maximum target/current target which will result in 00000000FFFF0000000000000000000000000000000000000000000000000000 / 0000000000000000000da8a10000000000000000000000000000000000000000 , equals to approximately 20607418304385.63 which is the current difficulty.
Now, since difficulty is a function of target, you can do it in reverse to obtain the next difficulty. When calculating the next difficulty, you'll be taking the expected time/actual time of the last 2015 blocks. Let's take for example the previous difficulty adjustment which was on 9 Jan 2021. The average block time was about 9 minutes and 2 seconds. The expected difficulty increment would be 600/542 which is roughly 10.7% increment. If you were to convert the new target from the new difficulty (18,599,593,048,299 x ~1.107), you would be using 00000000FFFF0000000000000000000000000000000000000000000000000000 / 20607418304385.63 which would give you a target of 0000000000000000000da8a10000000000000000000000000000000000000000.
You can actually just calculate the target without a conversion to the difficulty but I wanted to show how they're linked. Given that the network attempts to keep the block interval at an average of 10 minutes, the difficulty adjustment is based on the deviation from the expected time and uses it to calculate the difficulty
increase, or the
decrease in the target. They have an inverse relationship.