Saturday, November 6, 2010

Decimal to binary

clg
font "arial",10,100
input "Number to change to binary up to 1024 ",a
n=10
dim b(n+1)
do
if a-2^n>-1 then
b[n]=1
a=a-2^n
end if
n=n-1
until n<0
for x = 0 to 10
text 290-x*25+10,10,b[x]
text 290-x*25+10,30,b[x]*2^x
next x

No comments:

Post a Comment