private long inverse ( double current ) { // Represent to base b. short [ ] digits = new short [ maxi ] ; for ( int j = 0 ; j < maxi ; j ++ ) { current *= base ; digits [ j ] = ( short ) current ; current -= digits [ j ] ; if ( current <= 1e-10 ) { break ; } } long inv = 0 ; for ( int j = maxi - 1 ; j >= 0 ; j -- ) { inv = inv * base + digits [ j ] ; } return inv ; }
Compute the inverse with respect to the given base .