Go Down

Topic: Questions about Stream parse functions in Arduino 1.0 beta 3 (Read 1 time) previous topic - next topic


Here are three questions about Stream::parseInt() and Stream::parseFloat().

1. Why do they skip all leading characters except '-' and digits 0-9?  Why not just space like most parse functions?  Reading "abc123" as a valid number, 123, seems strange.

2. How can you tell if no digits were read?  The string "xyz" returns zero.

3. Why do they swallow the terminating non-digit?  Often this character is important.  If you call parseInt() with the string "567pq", 'p' is consumed and the next read returns 'q'.

Go Up