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.