Hacker News new | past | comments | ask | show | jobs | submit login

Or you could just convert from the unsigned to the signed type, rather than dragging unions into it.

This conversion doesn't have undefined behavior; it produces an implementation defined result.

C programs can simulate two's complement math using unsigned types, avoiding UB. Then rely on IB to convert between signed and unsigned.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: