Improved fast_atof

pull/261/head
Léo Terziman 2013-11-25 11:22:31 +01:00
parent d28fc25c5c
commit 3e55dca943
1 changed files with 4 additions and 1 deletions

View File

@ -179,6 +179,9 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
unsigned int cur = 0;
uint64_t value = 0;
if ( *in < '0' || *in > '9' )
throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value.");
bool running = true;
while ( running )
{
@ -188,7 +191,7 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
if (new_value < value) /* numeric overflow, we rely on you */
return value;
throw std::overflow_error(std::string("Converting the string \"") + in + "\" into a value resulted in overflow.");
value = new_value;