Allow numbers starting with decimal in fast_atof.
parent
d655199043
commit
3e9fab3bfc
|
@ -229,14 +229,25 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
|
|||
template <typename Real>
|
||||
inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma = true)
|
||||
{
|
||||
Real f;
|
||||
Real f = 0;
|
||||
|
||||
bool inv = (*c == '-');
|
||||
if (inv || *c == '+') {
|
||||
++c;
|
||||
}
|
||||
|
||||
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
||||
if (!isdigit(*c) && !(*c == '.' && isdigit(c[1])))
|
||||
{
|
||||
throw std::invalid_argument("Cannot parse string "
|
||||
"as real number: does not start with digit "
|
||||
"or decimal point followed by digit.");
|
||||
}
|
||||
|
||||
if (*c != '.')
|
||||
{
|
||||
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
||||
}
|
||||
|
||||
if ((*c == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')
|
||||
{
|
||||
++c;
|
||||
|
|
Loading…
Reference in New Issue