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 [00000000] )  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 [00000000] )  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 [00000000] )  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  
 
 [ 3 post ] 

 Relevant Pages 

1. LOGO-L> Re: Question: Binary Numbers

2. convert binary number to binary string

3. Binary number -> Integer number

4. 64 bit binary number

5. Writing double word binary numbers on screen

6. Smalltalk Number to EBCDIC Packed/Binary format Conversion

7. Number of Records in a DOS(Binary) table.

8. Converting a binary string to a number...

9. Converting a hex number to binary

10. Convert decimal number to Binary represented ??

11. Read/Write binary floating point numbers

12. (16 bit binary number) * 5.5

 

 
Powered by phpBB® Forum Software