#NEWLINE# def dec_to_bcd_excess3( num , bias = 3 ) : #NEWLINE# #INDENT# "Converts a binary to Binary Coded Decimal, then converts again to\n    excess-3 BCD, which has a 'bit bias' of `bias`, where bits are\n    shifted by the given bias. See wikipedia.org/wiki/Excess-3 for more." #NEWLINE# ( bcd , binary , decimals ) = ( '' , '' , '' ) #NEWLINE# for digit in str ( num ) : #NEWLINE# #INDENT# binval = encoders . dec_to_bin ( int ( digit ) ) #NEWLINE# binval = BaseDataType . add ( str ( binval ) , bias ) #NEWLINE# binary += '{}{}' . format ( binval , ( ' ' * ( ( 4 - len ( binval ) ) + 1 ) ) ) #NEWLINE# if ( len ( binval ) < 4 ) : #NEWLINE# #INDENT# binval = binval . zfill ( 4 ) #NEWLINE# #UNINDENT# bcd += '{} ' . format ( binval ) #NEWLINE# decimals += ( binary + ( ' ' * 4 ) ) #NEWLINE# #UNINDENT# _show_bcd ( num , decimals , binary , bcd ) #NEWLINE# return bcd