Changeset 940


Ignore:
Timestamp:
06/01/20 13:21:50 (5 years ago)
Author:
Maciej Komosinski
Message:

More flexible underflow detection in ExtValue::parseNumber()

File:
1 edited

Legend:

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

    r925 r940  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1313#include <common/Convert.h>
    1414#include <climits>
     15#include <float.h>
    1516#include <errno.h>
    1617
     
    10711072        {
    10721073                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                if (fabs(fpvalue) < DBL_MIN) errno = 0; //Underflow OK. Otherwise we have overflow: +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
    10741075        }
    10751076        if ((after > in) && (errno == 0))
Note: See TracChangeset for help on using the changeset viewer.