def convert_to_bcd(decimal):
 (place, bcd) = (0, 0)
 while (decimal > 0):
  nibble = (decimal % 10)
  bcd += (nibble << place)
  decimal /= 10
  place += 4
 return bcd

def convert_to_bcd ( decimal ) : ( place , bcd ) = ( 0 , 0 ) while ( decimal > 0 ) : nibble = ( decimal % 10 ) bcd += ( nibble << place ) decimal /= 10 place += 4 return bcd
converts a decimal value to a bcd value .