Difference between revisions of "Bit"

From Vendetta Lua
Jump to: navigation, search
(tobits)
(Functions)
Line 3: Line 3:
 
=== band ===
 
=== band ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.band(w1,...)
+
bit.band(w1,w2)
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 13: Line 13:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.band (15, 3)) --> 3
 
<br><br>
 
<br><br>
  
 
=== bor ===
 
=== bor ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.bor(w1,...)  
+
bit.bor(w1,w2)  
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 27: Line 28:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.bor (13, 17)) --> 29
 
<br><br>
 
<br><br>
  
Line 41: Line 43:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print(bit.bnot(10)) --> 4294967285
 
<br><br>
 
<br><br>
  
Line 55: Line 58:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.xor (15, 1)) --> 14
 
<br><br>
 
<br><br>
  
Line 69: Line 73:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.brshift (-1024, 6)) --> 4294967285
 
<br><br>
 
<br><br>
  
Line 81: Line 86:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.xor (15, 1)) --> 14
 
<br><br>
 
<br><br>
  
Line 109: Line 115:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.blshift (4, 6)) --> 256
 
<br><br>
 
<br><br>
  
Line 137: Line 144:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
 +
print (bit.blogic_rshift (144, 1)) --> 72
 
<br><br>
 
<br><br>

Revision as of 14:09, 31 May 2008

Functions

band

Definition:
bit.band(w1,w2)

Description:
returns the bitwise and of the w's

Arguments:


Returns:


Example:
print (bit.band (15, 3)) --> 3

bor

Definition:
bit.bor(w1,w2)

Description:
returns the bitwise or of the w's

Arguments:


Returns:


Example:
print (bit.bor (13, 17)) --> 29

bnot

Definition:
bit.bnot(a)

Description:
returns the one's complement of a

Arguments:


Returns:


Example:
print(bit.bnot(10)) --> 4294967285

bxor

Definition:
bit.bxor(w1,...)

Description:
returns the bitwise exclusive or of the w's

Arguments:


Returns:


Example:
print (bit.xor (15, 1)) --> 14

brshift

Definition:
bit.rshift(a,b)

Description:
returns a shifted logically right b places

Arguments:


Returns:


Example:
print (bit.brshift (-1024, 6)) --> 4294967285

bxor2

Definition:


Description:


Arguments:


Returns:


Example:
print (bit.xor (15, 1)) --> 14

tonumb

Definition:
bit.tonumb(bit_tbl)

Description:
convert a bit table into a number

Arguments:


Returns:


Example:


blshift

Definition:
bit.lshift(a,b)

Description:
returns a shifted left b places

Arguments:


Returns:


Example:
print (bit.blshift (4, 6)) --> 256

tobits

Definition:
bit.tobits(n)

Description:
convert n into a bit table(which is a 1/0 sequence), high bits first

Arguments:


Returns:


Example:


blogic_rshift

Definition:
bit.blogic_rshift(n, bits)

Description:
logic right shift(zero fill >>>)

Arguments:


Returns:


Example:
print (bit.blogic_rshift (144, 1)) --> 72