Or if you didn't want to waste time creating a string (I mean execution time), you could just use the mod operator ( % ) to get the remainder after dividing by 10, that would give you the units. To get tens, divide by 10 then mod 10. To get 100s, divide by 100 then mode 10. You could use a function like this:
posotion 0 is the units, 1 is tens, 2 is hundreds, etc.PHP Code:int getDigit(int iPosition, int iNumber, int iRadix)
{
for(int i=0; i<iPosition; i++)
iNumber /= iRadix;
return(iNumber % iRadix);
}




Reply With Quote