Parsing an integer from text
Parsing an integer is relatively simple depending on how many checks you make. This loop does almost no validation. The input can multiple '-' signs and the number can overflow. As soon as it reaches a character is does not accept to stops. It is left to the caller to check if this character was a valid separartor.Note: The expression (b >= '0' && b <= '9') has been re-written taking advantage of an underflow to turn this into one comparison.
No comments:
Post a Comment