Question: Binary Numbers
Author Message Question: Binary Numbers

Is it possible to work with binary numbers in
winlogo, without having to process them as a
list of numbers (eg  )  I'd like
to do something like 00000001b + 1b = 00000010b

I've got a project I really should do in
C++, but I know I'll be using winlogo next term,
so would like to practice.

Thanks

Scott

Sun, 05 Mar 2000 03:00:00 GMT  Question: Binary Numbers

Quote:

>Is it possible to work with binary numbers in
>winlogo, without having to process them as a
>list of numbers (eg  )  I'd like
>to do something like 00000001b + 1b = 00000010b

>Thanks

>Scott

I do not know the answer. But this reminds me of another question.
The largest number that can be represented in signed 32-bit number
is 32768 * 65536 -1 = 2147483647. It seems that the maximum recognizable
number in MicroWorlds is about 12 digits. 2147483647 is only 10 digits.
So, the number representation and arith. operation in MicroWorlds may not
be in binary. That is, ASCII string representation of numbers
seem to be NOT converted into the native binary number and then
being computed using the native (machine) instructions.

Does anyone know how MicroWorlds handles the number arithmetics?
Thanks.

- Wen

Mon, 06 Mar 2000 03:00:00 GMT  Question: Binary Numbers

Quote:

>Is it possible to work with binary numbers in
>winlogo, without having to process them as a
>list of numbers (eg  )  I'd like
>to do something like 00000001b + 1b = 00000010b

You can write procedures to do binary arithmetic.

to add :a :b [:carry 0]
if and empty? :a empty? :b [output "]
output word (add butlast :a butlast :b int (((last :a)+(last :b)+:carry)/2)) ~
remainder ((last :a)+(last :b)+:carry) 2
end

something like that...  I'm making this up on the spur of the moment.
I haven't worried about handling inputs of different numbers of digits,
etc.

If you want to use very long binary numerals, quote them:

print add "101010101010101010101010101010 "0000000000000000111111111

Mon, 06 Mar 2000 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages