Difference between revisions of "Bitlib"

From Vendetta Lua
Jump to: navigation, search
(New page: == Functions == === band === '''Definition:'''<br> bit.band(w1,w2,...) <br><br> '''Description:''' <br> returns the bitwise and of the w's <br><br> '''Example:'''<br> print (bit.band (15,...)
 
(Functions)
Line 14: Line 14:
 
=== bor ===
 
=== bor ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.bor(w1,w2,...)  
+
bitlib.bor(w1,w2,...)  
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 20: Line 20:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print (bit.bor (13, 17)) --> 29
+
print (bitlib.bor (13, 17)) --> 29
 
<br><br>
 
<br><br>
  
 
=== bnot ===
 
=== bnot ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.bnot(a)
+
bitlib.bnot(a)
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 31: Line 31:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print(bit.bnot(10)) --> 4294967285
+
print(bitlib.bnot(10)) --> 4294967285
 
<br><br>
 
<br><br>
  
 
=== bxor ===
 
=== bxor ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.bxor(w1,...)  
+
bitlib.bxor(w1,...)  
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 42: Line 42:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print (bit.xor (15, 1)) --> 14
+
print (bitlib.xor (15, 1)) --> 14
 
<br><br>
 
<br><br>
  
 
=== rshift ===
 
=== rshift ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.shift(a,b)
+
bitlib.shift(a,b)
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 53: Line 53:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print (bit.rshift (-1024, 6)) --> 67108848
+
print (bitlib.rshift (-1024, 6)) --> 67108848
 
<br><br>
 
<br><br>
  
Line 59: Line 59:
 
=== arshift ===
 
=== arshift ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.arshift(a,b)
+
bitlib.arshift(a,b)
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 65: Line 65:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print (bit.arshift (-1024, 6)) --> -16
+
print (bitlib.arshift (-1024, 6)) --> -16
 
<br><br>
 
<br><br>
  
Line 71: Line 71:
 
=== lshift ===
 
=== lshift ===
 
'''Definition:'''<br>
 
'''Definition:'''<br>
bit.lshift(a,b)
+
bitlib.lshift(a,b)
 
<br><br>
 
<br><br>
 
'''Description:''' <br>
 
'''Description:''' <br>
Line 77: Line 77:
 
<br><br>
 
<br><br>
 
'''Example:'''<br>
 
'''Example:'''<br>
print (bit.lshift (-1024, 6)) --> 4294901760
+
print (bitlib.lshift (-1024, 6)) --> 4294901760
 
<br><br>
 
<br><br>

Revision as of 06:33, 14 June 2008

Functions

band

Definition:
bit.band(w1,w2,...)

Description:
returns the bitwise and of the w's

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

bor

Definition:
bitlib.bor(w1,w2,...)

Description:
returns the bitwise or of the w's

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

bnot

Definition:
bitlib.bnot(a)

Description:
returns the one's complement of a

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

bxor

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

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

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

rshift

Definition:
bitlib.shift(a,b)

Description:
returns a shifted logically right b places

Example:
print (bitlib.rshift (-1024, 6)) --> 67108848


arshift

Definition:
bitlib.arshift(a,b)

Description:
returns a shifted logically right b places

Example:
print (bitlib.arshift (-1024, 6)) --> -16


lshift

Definition:
bitlib.lshift(a,b)

Description:
returns a shifted logically left b places

Example:
print (bitlib.lshift (-1024, 6)) --> 4294901760