|
|
|
|
|
by MaxBarraclough
2020 days ago
|
|
The overflow happens in the computation, you don't typically determine whether there was an overflow by checking the variable into which the result is saved (although perhaps this approach could work if you're using an unsigned integer type, which wraps around on overflow). You'd normally perform the check before you perform the addition (or whichever operation risks overflow). This can be fiddly to get right, but it's possible. Also, the maximum value that can be represented in a variable of type uint32_t is (2^32) - 1, not 2^32. |
|