strtod#

Parse a double from the start of a string, locale-aware.

Σύνοψη#

use POSIX qw(strtod);
my ($num, $unparsed) = strtod("3.14abc");   # (3.14, 3)

Τι επιστρέφεται#

A two-element list: the parsed value and the number of bytes that did not form part of the number. When $unparsed == 0, the whole string was consumed.

Οριακές περιπτώσεις#

  • Input that doesn’t start with a number: returns (0, length).

  • Overflow: returns HUGE_VAL and sets $! to ERANGE.

Διαφορές από το upstream#

Fully compatible with upstream POSIX.

Δείτε επίσης#

  • strtol, strtoul - integer variants.