2 ms·
> ... this explicitly relies on shifting something into the sign bit, which depending on the exact flavor of language standard you’re using is either not allowe
by eqvinox 2y ago
> ... this explicitly relies on shifting something into the sign bit, which depending on the exact flavor of language standard you’re using is either not allowed or at best fairly recently ..
An unsigned has no sign bit, so the left shift just needs to be unsigned to make it "technically correct".
(Remember to not use smaller than int types though, due to integer promotion issues)
- fluoridation 2y agoYup. When you're twiddling bits you're better off using unsigned types in general anyway, and leaving converting to a signed type at the very end.