This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-06 14:40:31

frowned
Scratcher
Registered: 2010-11-02
Posts: 42

[tutorial] Bitwise Operations:

here is a list of operations and their code:
AND

Code:

and: bin n: n
      ^ bin bitAnd: n

OR

Code:

or: bin n: n
      ^ bin bitOr: n

XOR

Code:

xor: bin n: n
      ^ bin bitXor: n

< <

Code:

shiftleft: bin n: n
      ^ bin bitShift: n

> >

Code:

shiftright: bin n: n
      ^ bin bitShift: (n negated)

results:
http://dl.dropbox.com/u/20328726/binops.bmp

Last edited by frowned (2012-02-28 14:14:10)

Offline

 

#2 2011-09-11 03:54:14

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: [tutorial] Bitwise Operations:

What do these do?

Offline

 

#3 2011-09-11 05:11:54

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: [tutorial] Bitwise Operations:

bitwise operations:

1010101010 XOR 1111111111 = 0101010101
1010101010 AND 1111111111 = 1010101010
1010101010 OR  1111111111 = 1111111111
1111100 >> 2 = 0011111
...

Last edited by roijac (2011-09-11 05:12:58)

Offline

 

#4 2011-12-01 17:26:17

frowned
Scratcher
Registered: 2010-11-02
Posts: 42

Re: [tutorial] Bitwise Operations:

exactly

Offline

 

Board footer