Tomasm,

Thanks to misk's question I found that there is one number out of 60,000 that that formula has a problem with.

39321 the result ends up as 0001:FFFF instead of 0000:FFFF.

here's a possible fix:
Code:
a          var  word      ' 0-60000
result     var  word[2]   ' 32-bit result, although largest is 17-bit
 ResHigh   var  result[1]
 ResLow    var  result[0]

a = 60000    ' a test number

ResLow = a / 3
if a <> 39321 then
    ResHigh = ((ResLow - 13107) >> 15) ^ 1
else
    ResHigh = 0
endif
ResLow = ResLow * 5 + (a // 3 * 15 / 10)
Not pretty, but it's works better.

Best regards,
&nbsp;&nbsp;&nbsp;Darrel