[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA4.0 : Bug with maths (constructive)
- From: "paulmatthews" <paulmatthews@...>
- Date: Mon, 11 Feb 2002 03:53:47 -0000
How about if tonumber() did something like the following. Will work
if NaN support exists or not. Will exit() on tonumber("Hello")
however .... so might need a bit of work ;-)
double tonumber( const char *str )
{
double result;
char *endptr = (char*)str;
if( str != NULL ) {
errno=0;
result = strtod( str, &endptr );
}
if( endptr == str )
errno = EINVAL;
if( errno ) {
perror( "tonumber()" );
exit(errno);
}
return result;
}