4 ms·
Nope, casting signed to unsigned is well-defined. The C standard requires it to act like two’s complement regardless of what the machine actually uses: > Othe
by comex 9y ago
Nope, casting signed to unsigned is well-defined. The C standard requires it to act like two’s complement regardless of what the machine actually uses:
> Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
https://stackoverflow.com/questions/50605/signed-to-unsigned-conversion-in-c-is-it-always-safe https://stackoverflow.com/questions/50605/signed-to-unsigned...
- popmatrix 9y ago~0u is also a safe equivalent if there is unwarranted fear around wrapping.