[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> Re: Question: Binary Numbers



That's just how I suggested to someone that they could do
infinite precision math. In any base, not just binary.

Although sin and cos could get a little tricky :-)

Brian wrote:
> 
> slary61@MAINE.EDU writes:
> >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
> 
> 

-- 
===============================================================
George Mills (mills@softronix.com)
http://www.softronix.com/
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home