private short expectedExponent ( ) { // since the log of 0, or the log base 0 of something, causes an // error, declare the exponent in these cases to be 0 (we also // deal with the special-rule identifiers here) if ( radix == 0 || baseValue < 1 ) { return 0 ; } // we get rounding error in some cases-- for example, log 1000 / log 10 // gives us 1.9999999996 instead of 2. The extra logic here is to take // that into account short tempResult = ( short ) ( Math . log ( baseValue ) / Math . log ( radix ) ) ; if ( power ( radix , ( short ) ( tempResult + 1 ) ) <= baseValue ) { return ( short ) ( tempResult + 1 ) ; } else { return tempResult ; } }
This calculates the rule s exponent based on its radix and base value . This will be the highest power the radix can be raised to and still produce a result less than or equal to the base value .