Hi!

Consider this code:

Code:
Divisor VAR byte[5]
H VAR WORD
b VAR BYTE
w VAR WORD

powerTen:            ' for BCD conversion
  select case b
    case 0: w = 1
    case 1: w = 10
    case 2: w = 100
    case 3: w = 1000
    case 4: w = 10000
  end select
return

 H=37234 

 'convert to BCD and fill divisor 
         FOR b = 0 to 4
            gosub powerTen
            divisor [b] = (H/w) & $0f
         next b
      ENDIF
Suspecting that "(H/w) & $0f" does not work as one would think, that is
w=1 -> 37234/1 = 37234 & $F -> 4
w=2 -> 37234/10= 3723.4 & $F = 3723 -> 3
w=3 -> 37234/100=372.34 & $F= 372 -> 2
w=4 -> 37234/1000=37,234 & $F=37 -> 7
w=5 -> 37234/10000=3.7234 & $F=3 -> 3

The array is filled with 3, that is 33333 !

The goal is to find in that array 37234...

So I fail to understand what is wrong and how to amend?

Can anybody explain why that code doesn't work

Thanks