This code is supposed to tell me the number of digits to the right of the decimal. It works sometimes (with some numbers), and other times it just sits there and I have to shut it down with my task manager (program not responding). I thought it may be getting stuck in the outer for loop, so that's why I have the escape things commented out in there... Some examples, it works for .25, but not for .3, what's going on??

Thanks,

Sean

SeanMSimonsen@cs.com

int Decimals(double number) // Tells how many digits are to the right of the decimal in a number

{

int decimals = 0;

// int escape = 0;

for( ; /* escape == 0 */; )

{

for( double counter = 0; ; counter++ )

{

if( counter >= number )

{

break;

}

}

if( number != counter )

{

decimals++;

number *= 10;

}

else

break; /* escape = 1; */

}

return decimals;

}