Can be discussed, of course. Your example string would, with the old function, result to −118773544 (or
4176193751 as unsigned) for "$" would count -12 and "," would count -4. So the old version had just given senseless results, stopping seemed more sensible to me.
I've used it to parse a string like
" 12=1446"
It's meant for presets which can be typed in via serial console and stored in data eeprom.
Parsing is very simple. First, a for loop replaces every " " with "0". Then, the number is evaluated which stops at the "=", and I have the address which is to be changed.
Then, a byte*x variable laid over the string is >>8 until the first character is a "=". Then, the first character is set to "0", the string is evaluated again, and I have the value which should be stored at the address just found.
Yes, could be done by replacing the "=" with ASCII_NULL. How about this: Like in jal source code, underscores are ignored, any other char stops the conversion? Your example could be easily converted to "_123_456" without moving parts of the string, which can be difficult (and error-prone) indeed.
Ok, I could live with stopping at ASCII_NULL and ignoring any other non-number char.
Any additional opinions?
Greets,
Kiste