Gday Atomski
If you will never go above 777, you can use a little trick by adding 1000, to ensure you always get yr leading zeroes for the DIG cmd
Numsend = 17
Numsend = 1000 + 17 ' ie now you have 1017 and DIG gets the zero in pos 2 no probs
output = %1 ' so you will always have a 1 in MSB
output = ( output << 3 ) + numsend dig 2 ' the leading zero
' ie %1000 + %000 = %1000
output = ( output << 3 ) + numsend dig 1 ' the 1
' ie %1000000 + %001 = %1000001
output = ( output << 3 ) + numsend dig 0 ' the 7
' ie %1000001000 + %111 = %1000001111
output shld now be in yr required format but will always have 10bits
dont process the MSB bit and yr away
Andrew
Bookmarks