by __phantomderp · 4y ago · 0 comments
https://thephd.dev/c-the-improvements-june-september-virtual...
That makes parsing the unsigned variant relatively simple. Undefined behavior would be end-of-game, but unsigned addition and multiplication will not invoke that (if you need he,p, look at your favorite multiple-precision library for ideas about detecting wraparound)
For parsing signed integers, derive the min and max values of the signed variant from the max value of the unsigned one ((whatever_max - 1) / 2 or something like that
Then parse your input to the unsigned variant first, then check whether it fits in the unsigned version.
Someone's got to write a paper to get it in, hopefully based on some sort of existing practice.