Description

parseInt() returns the first valid (long) integer number from the current position. The function is terminated by the first character that is not a digit (except for the leading minus sign), or when it times out (see Stream.setTimeout()).

This function is part of the Stream class, and can be called by any class that inherits from it (Wire, Serial, etc). See the Stream class main page for more information.

Syntax

  • stream.parseInt()
  • stream.parseInt(lookahead)
  • stream.parseInt(lookahead, ignore)

Parameters

  • lookahead: the mode used to look ahead in the stream for an integer. Allowed data types: LookaheadMode. Allowed values:
    • SKIP_ALL: all characters other than digits or a minus sign are ignored when scanning the stream for an integer. This is the default mode.
    • SKIP_NONE: nothing is skipped, and the stream is not touched unless the first waiting character is valid.
    • SKIP_WHITESPACE: only tabs, spaces, line feeds, and carriage returns are skipped.
  • ignore: character to skip in the search, used for example to skip thousands dividers. Allowed data types: char.

Returns

The first valid integer number, or 0 if no valid number is found. Data type: long.