Commit bf6ae0a8 authored by Michael Pyne's avatar Michael Pyne
Browse files

Merging in some improvements to HNumber from Ariya.

* Convert out-of-range values in string ctor to NaN.
* Add to test suite.

svn path=/trunk/playground/utils/abakus/; revision=472160
parent 1967b29d
......@@ -369,6 +369,12 @@ HNumber::HNumber( const char* str )
d->num = h_str2num( s );
delete [] s;
if( expd >= HMATH_MAX_PREC || // too large
expd <= -HMATH_MAX_PREC ) // too small
{
d->nan = true;
}
if( expd != 0 )
{
bc_num factor = h_raise10( expd );
......@@ -1362,6 +1368,10 @@ void test_create()
CHECK( HNumber("1.0"), "1" );
CHECK( HNumber("2.0"), "2" );
CHECK( HNumber("1e-3"), "0.001" );
// too large or small
CHECK( HNumber("1e200"), "NaN" );
CHECK( HNumber("1e-200"), "NaN" );
}
void test_format()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment