Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
thomashabets2
1mo ago
0 comments
Save
Share
If that's an error then so is passing in a non number.
So catch 22. You can only check for valid numbers if the number is valid?
0 comments
4 comments · 2 top-level
top
newest
oldest
rbanffy
1mo ago
· 1 in thread
If you pass a negative number as a string to a function that converts strings representing positive numbers into positive long integers, then yes, it should return an error status instead of the wrong result.
thomashabets2
OP
1mo ago
Ah, I misunderstood what you meant by "is an error". Agree.
imtringued
1mo ago
· 1 in thread
That's the C way, yes.
thomashabets2
OP
1mo ago
No. This is more like if strcmp compared null terminates strings, but can only compare strings that are in fact equal.
j
/
k
navigate · click thread line to collapse