HugeInt::HugeInt( long value )
:size(0)
{
// initialize array to zero
for ( int i = 0; i < digits; i++ )
integer[ i ] = 0;
// place digits of argument into array
for ( int j = digits - 1; value != 0 && j >= 0; j-- )
{
integer[ j ] = value % 10;
value /= 10;
} // end for
//???size = sizeof(value);
} // end HugeInt default/conversion constructor
HugeInt::HugeInt( const string &number )
:size(0)
{
size = sizeof(number);
// initialize array to zero
for ( int i = 0; i < digits; i++ )
integer[ i ] = 0;
// place digits of argument into array
int length = number.size();
// int size = strlen( &number );
for ( int j = digits - length, k = 0; j < digits; j++, k++ )
if ( isdigit( number[ k ] ) ) //ensure that char is digit
integer[ j ] = number[ k ] - '0';
} // end HugeInt conversion constructor
|