implement positive integer encode