Quote Originally Posted by rlampus
Could you please give one example of actual pic basic code.
As I have said in the past, there has got to be an easier way....but this might get your ball rolling. I worked it assuming you have no WORD variables and only BYTES. (i.e., I assumed you had a 16 bit number composed of two 8 bit variables instead of your 32 bit number composed of two 16 bit words. Expanding the below to DOUBLE WORDS is similar, just a lot more lines.) (Yes, I know we have WORDS in PBP – I am just demonstrating a process). -THIS IS UNTRIED IN ACTUAL CODE BUT WORKS ON PAPER-

Background
bit 1 = 1
bit 2 = 2
bit 3 = 4
bit 4 = 8
bit 5 = 16
bit 6 = 32
bit 7 = 64
bit 8 = 128
----------------
bit 9 = 256
bit 10 = 512
bit 11 = 1024
bit 12 = 2048
bit 13 = 4096
bit 14 = 8192
bit 15 = 16384
bit 16 = 32768

Code:
' Example: Dig 12345 (assuming WORDS not available)
HiByte VAR BYTE
LoByte VAR BYTE
Digit VAR byte[5]
HiByte = $30	' high byte of 12345 ($30 = 00110000)
LoByte = $39 ' low byte of 12345

Digit[0] = LoByte Dig 0	' = 7
Digit[1] = LoByte Dig 1	' = 5
Digit[2] = LoByte Dig 2	' = 0
Digit[3] =  0	' no need to dig because byte 3 decimal places max
Digit[4] =  0	' no need to dig because byte 3 decimal places max

If HiByte.0 = 1 then
	Digit[0] = Digit[0] +6	
	Digit[1] = Digit[1] +5	
	Digit[2] = Digit[2] +2	
If HiByte.1 = 1 then
	Digit[0] = Digit[0] +2
	Digit[1] = Digit[1] +1
	Digit[2] = Digit[2] +5
	
If HiByte.2 = 1 then
	Digit[0] = Digit[0] +4
	Digit[1] = Digit[1] +2
	Digit[3] = Digit[3] +1
	
If HiByte.3 = 1 then
	Digit[0] = Digit[0] +8	
	Digit[1] = Digit[1] +4		
	Digit[3] = Digit[3] +2	
	
If HiByte.4 = 1 then
	Digit[0] = Digit[0] +6	'=13
	Digit[1] = Digit[1] +9	'=14
	Digit[3] = Digit[3] +4	'=4
	
If HiByte.5 = 1 then
	Digit[0] = Digit[0] +2	'=15
	Digit[1] = Digit[1] +9	'=23
	Digit[2] = Digit[2] +1	'=1
	Digit[3] = Digit[3] +8	'=12
	
If HiByte.6 = 1 then
	Digit[0] = Digit[0] +4
	Digit[1] = Digit[1] +8
	Digit[2] = Digit[2] +3
	Digit[3] = Digit[3] +6
	Digit[4] = Digit[4] +1

If HiByte.7 = 1 then
	Digit[0] = Digit[0] +8
	Digit[1] = Digit[1] +6
	Digit[2] = Digit[2] +7
	Digit[3] = Digit[3] +2
	Digit[4] = Digit[4] +3

Digit[1] = Digit[1] + Digit[0] Dig 1		'=24
Digit[0] = Digit[0] Dig 0			'=5  DIGIT0
Digit[2] = Digit[2] + Digit[1] Dig 1		'=3
Digit[1] = Digit[1] Dig 0			'=4  DIGIT1
Digit[3] = Digit[3] + Digit[2] Dig 1		'=12
Digit[2] = Digit[2] Dig 0			'=3  DIGIT2
Digit[4] = Digit[4] + Digit[3] Dig 1		'=1 DIGIT4
Digit[3] = Digit[3] Dig 0			'=2  DIGIT3
Good Luck