protected long calculatePowerOfTwo ( long attempt ) { long step ; if ( attempt >= 64 ) { //safeguard against overflow in the bitshift operation step = Long . MAX_VALUE ; } else { step = ( 1L << ( attempt - 1 ) ) ; } //round will cap at Long.MAX_VALUE return Math . round ( step * growBy ) ; }
fastpath with bitwise operator