Bitlib

From Vendetta Lua
Revision as of 06:31, 14 June 2008 by BlackNet (Talk | contribs) (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,...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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:
bit.bor(w1,w2,...)

Description:
returns the bitwise or of the w's

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

bnot

Definition:
bit.bnot(a)

Description:
returns the one's complement of a

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

bxor

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

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

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

rshift

Definition:
bit.shift(a,b)

Description:
returns a shifted logically right b places

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


arshift

Definition:
bit.arshift(a,b)

Description:
returns a shifted logically right b places

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


lshift

Definition:
bit.lshift(a,b)

Description:
returns a shifted logically left b places

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