why is double negation useful in shiftOut for example?

This code fancifully fixes its own oversight - The effort to shift the bit to the LSB arises because it is not in the "right" position. This can be avoided by shifting the tested bit into the LSB instead, like:

digitalWrite(dataPin, (val >> i) & HIGH );