3 ms·
> For example (short) -1 (0xffff) becomes 2^32-1 (0xffffffff) when casted to uint32_t. Ideally the compiler would do a check during a conversion from a negativ
by winter_blue 10y ago
> For example (short) -1 (0xffff) becomes 2^32-1 (0xffffffff) when casted to uint32_t.
Ideally the compiler would do a check during a conversion from a negative signed integer to unsigned integer, and set a flag or throw some sort of exception. Hopefully future languages (e.g. Rust) learn from this.