#NEWLINE# def _ExtendByZeros( crc , num_bits ) : #NEWLINE# #INDENT# 'Given crc representing polynomial P(x), compute P(x)*x^num_bits.\n\n  Args:\n    crc: crc respresenting polynomial P(x).\n    num_bits: number of bits in crc.\n\n  Returns:\n    P(x)*x^num_bits\n  ' #NEWLINE# def _ReverseBits32( crc ) : #NEWLINE# #INDENT# return int ( '{0:032b}' . format ( crc , width = 32 ) [ : : ( - 1 ) ] , 2 ) #NEWLINE# #UNINDENT# crc = _ReverseBits32 ( crc ) #NEWLINE# i = 0 #NEWLINE# while ( num_bits != 0 ) : #NEWLINE# #INDENT# if ( num_bits & 1 ) : #NEWLINE# #INDENT# crc = _CrcMultiply ( _ReverseBits32 , X_POW_2K_TABLE [ ( i % len ( X_POW_2K_TABLE ) ) ] ) #NEWLINE# #UNINDENT# i += 1 #NEWLINE# num_bits >>= 1 #NEWLINE# #UNINDENT# crc = _ReverseBits32 ( crc ) #NEWLINE# return crc