Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Sharlin
34 days ago
|
parent
|
context
|
favorite
| on:
No way to parse integers in C (2022)
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
34 days ago
[–]
you could check if ret > ret * 10 + characters[i]-48, if so it has wrapped around and you return an error
thomashabets2
34 days ago
|
parent
[–]
For unsigned that could work, but signed overflow is UB.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: