Pages: [1]   Go Down
Author Topic: Questions about Stream parse functions in Arduino 1.0 beta 3  (Read 1089 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
Karma: 67
Posts: 1654
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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'.

Pages: [1]   Go Up
Jump to: