23 lines
343 B
Plaintext
23 lines
343 B
Plaintext
rem - Return binary representation of n
|
|
|
|
function bin$(n = integer) = string
|
|
var s = string
|
|
s = ""
|
|
while n > 0 do
|
|
begin
|
|
if (n - (n / 2) * 2) = 0 then
|
|
s = "0" + s
|
|
else
|
|
s = "1" + s
|
|
n = n / 2
|
|
end
|
|
end = s
|
|
|
|
rem - exercise the function
|
|
|
|
print "5 = "; bin$(5)
|
|
print "50 = "; bin$(50)
|
|
print "9000 = "; bin$(9000)
|
|
|
|
end
|