Changeset 925 for cpp/frams


Ignore:
Timestamp:
05/25/20 15:06:41 (4 years ago)
Author:
Maciej Komosinski
Message:

Handling errno==ERANGE when parsing numbers by strtod()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/extvalue.cpp

    r851 r925  
    10681068        errno = 0;
    10691069        double fpvalue = strtod(in, &after);
     1070        if (errno == ERANGE)
     1071        {
     1072                logPrintf("ExtValue", "parseNumber", LOG_WARN, "Unrepresentable number and strtod() signalled ERANGE: parsed %d chars of '%s' and returned '%f'", after - in, in, fpvalue);
     1073                if (fpvalue == 0) errno = 0; //otherwise we have +inf or -inf from a string number because it was too large for double-type, and we don't want to have infinities in ExtValue so we leave errno!=0
     1074        }
    10701075        if ((after > in) && (errno == 0))
    10711076        {
Note: See TracChangeset for help on using the changeset viewer.