You are right, the formula is inverted here. Someone reported the same issue already to the repository for the book.
I think confusion arises from there being two relevant terms here:
- target: the upper bound for the hash of an acceptable block. A higher target is easier to fit under, a lower target is harder. A representation of this value is stored in the
nBits
header field.
- difficulty: a human readable representation of the target relative to the difficulty of the maximal target (i.e. the minimum difficulty). Difficulty goes up when it gets harder to find blocks.
It looks like the difficulty and target was mixed up here. Either
New Difficulty = Old Difficulty * (20,160 minutes / Actual Time of Last 2015 Blocks)
or
New Target = Old Target * (Actual Time of Last 2015 Blocks / 20,160 minutes)
would be correct, but the book has a mistake here.