I first encountered this in the Flac source[1]. They do the bit twiddling a bit differently than in this article:
uval = (val<<1) ^ (val>>31);
Variations of this have probably been used countless of times in other libraries.[1] https://github.com/LordJZ/libflac/blob/master/src/libFLAC/bi...