It does work just for only some of them its correct
for example with the following test data and showing what should be
1 gives 1........................proper answer 00000001
2 gives 10......................proper answer 00000010
3 gives 101....................proper answer 00000011
4 gives 100....................proper answer 00000100
5 gives 1101..................proper answer 00000101
6 gives 1010..................proper answer 00000110
7 gives 1001..................proper answer 00000111
8 gives 1000..................proper answer 00001000
9 gives 11001................proper answer 00001001
10 gives 11010..............proper answer 00001010
An easy method of converting decimal to binary number equivalents is to write down the decimal number and to continually divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero
ok fixed it had to use the trunc command
do
for decimal = 1 to 10
Print( "Binary number of "+str(decimal)+" is " +str(decimalToBinary(decimal)))
next decimal
sync()
loop
/* Function to convert a decimal number to binary number */
function decimalToBinary(n as float)
remainder as integer
binary as integer= 0: i as integer = 1
while(n <> 0)
remainder = MOD(n,2)
n = trunc(n/2.0)
binary= binary + (remainder*i)
i = i*10
endwhile
endfunction binary
fubar