Pregunta de entrevista de Oracle

Bit Rotation function.

Respuesta de la entrevista

Anónimo

17 abr 2017

Rotation (or circular shift) is an operation similar to shift except that the bits that fall off at one end are put back to the other end. # Max number of bits BITS = 8 def left_rotate(number, bits): """ Function to left rotate a number by the given bit count. """ return int('1'*BITS, 2) & ((number > (BITS - bits)))