4 ms·
> I am going to assume that you know the beginning and the end of sequence of digits. First, that's a strong assumption. But... > We check whether some value
by Karellen 3y ago
> I am going to assume that you know the beginning and the end of sequence of digits.
First, that's a strong assumption. But...
> We check whether some value exceeds 9, in which case we had a non-digit character.
Huh? You already know where the end of the digits is. At least, I thought you did? So why would this be necessary?
- JonChesterfield 3y agoYou know how many bytes you're going to want to read, and you know they're supposed to be decimal digits, but you also know they might not be.
- Karellen 3y agoI don't understand how that is supposed to resolve the contradiction.
- joe_guy 3y ago> We check whether some value exceeds 9, If I'm seeing the misunderstanding here, the article with that statement is not talking about string length. They're talking about if non numerical input was given, ie, "a" would "exceed 9"
- Karellen 3y agoRight, but an "a" would be past the end of the digits, and the code assumes you know the end of the digits. It would make more sense if it was talking about the string length. Then you might find a non-digit before the end. But it specifically says you know where the end of the digits is, not the end of the string. Edit: Or, I'm trying to figure out what code might exist that found the end of the digits, but not always? The article says "assume you already know this", but computers aren't magic. There's code that figures out where the end of the digits is. So how does that code work, where it finds the end of the digits, but sometimes counts non-digits as digits?