Add method to encode a single digit.