3 ms·
Yes I checked the return value. Example using the program from https://news.ycombinator.com/item?id=38451560 https://news.ycombinator.com/item?id=38451560 $
by jstanley 3y ago
Yes I checked the return value. Example using the program from https://news.ycombinator.com/item?id=38451560 https://news.ycombinator.com/item?id=38451560
$ ./parse256 400
value of 400 is 144
- tom_ 3y ago400 is not an 8-bit integer! This function appears to be for parsing integers you know in advance will fit into 8 bits, rather than arbitrary input.
- jstanley 3y ago> The function returns a Boolean value indicating whether the input string can be parsed into an unsigned 8-bit integer or not. It returns 1 even though 400 is too large.
- tom_ 3y agoBut the parsed value was 144. It's less than 256! It fits! Indeed, all 3 conditions for returning true were satisfied. Just goes to show the value of accurate documentation: (Always safest to trust the docs. The code could easily be wrong!) - string is 3 chars or less - string contains no non-digit chars - parsed value is less than 256