2 ms·
And how does this avoid returning nonsense if the number is too large? (Wrapping if the accumulator is unsigned, straight to UB land if signed.) Not reporting o
by Sharlin 5mo ago
And how does this avoid returning nonsense if the number is too large? (Wrapping if the accumulator is unsigned, straight to UB land if signed.) Not reporting overflows as errors is one of the major problems demonstrated by TFA.
- voidUpdate 5mo agoyou could check if ret > ret * 10 + characters[i]-48, if so it has wrapped around and you return an error
- Thiez 5mo ago[dead]
- thomashabets2 5mo agoFor unsigned that could work, but signed overflow is UB.