Using Java btw. But Usually people seem to do this sort of thing with.
int numDigits = (int)(log10(num)+1); //can explicitly floor, or casting to int will do that
but log10(0) = -INF, which means my length is being set to the largest negative integer value.
I suppose I could make a condition
if (numDigits is negative)
numDigits = 1 //not 0 because I'm counting 0 as 1 digit.
This is being used to implement a natural number constructor, just so people have context to my problem.