Difference between revisions of "Bit"
(→Functions) |
(→Functions) |
||
(4 intermediate revisions by the same user not shown) | |||
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> | ||
returns the bitwise and of the w's | returns the bitwise and of the w's | ||
− | |||
− | |||
− | |||
− | |||
<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> | ||
returns the bitwise or of the w's | returns the bitwise or of the w's | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.bor (13, 17)) --> 29 | ||
<br><br> | <br><br> | ||
Line 35: | Line 29: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
returns the one's complement of a | returns the one's complement of a | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print(bit.bnot(10)) --> 4294967285 | ||
<br><br> | <br><br> | ||
Line 49: | Line 40: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
returns the bitwise exclusive or of the w's | returns the bitwise exclusive or of the w's | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.xor (15, 1)) --> 14 | ||
<br><br> | <br><br> | ||
Line 63: | Line 51: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
returns a shifted logically right b places | returns a shifted logically right b places | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.brshift (-1024, 6)) --> 4294967285 | ||
<br><br> | <br><br> | ||
=== bxor2 === | === bxor2 === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
− | <br><br> | + | <br><br> (HTTPLIB) |
− | '''Description | + | '''Description:''' <br> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.xor (15, 1)) --> 14 | ||
<br><br> | <br><br> | ||
=== tonumb === | === tonumb === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
+ | bit.tonumb(bit_tbl) (HTTPLIB) | ||
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
− | + | convert a bit table into a number | |
− | + | ||
− | + | ||
− | + | ||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 97: | Line 77: | ||
=== blshift === | === blshift === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
− | bit.lshift(a,b) | + | bit.lshift(a,b) (HTTPLIB) |
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
returns a shifted left b places | returns a shifted left b places | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.blshift (4, 6)) --> 256 | ||
<br><br> | <br><br> | ||
=== tobits === | === tobits === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
+ | bit.tobits(n) (HTTPLIB) | ||
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
− | + | convert n into a bit table(which is a 1/0 sequence), high bits first | |
− | + | ||
− | + | ||
− | + | ||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 123: | Line 98: | ||
=== blogic_rshift === | === blogic_rshift === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
− | bit.blogic_rshift(n, bits) | + | bit.blogic_rshift(n, bits) (HTTPLIB) |
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
logic right shift(zero fill >>>) | logic right shift(zero fill >>>) | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
+ | print (bit.blogic_rshift (144, 1)) --> 72 | ||
<br><br> | <br><br> |
Latest revision as of 19:26, 5 June 2008
Contents
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
brshift
Definition:
bit.rshift(a,b)
Description:
returns a shifted logically right b places
Example:
print (bit.brshift (-1024, 6)) --> 4294967285
bxor2
Definition:
(HTTPLIB)
Description:
Example:
print (bit.xor (15, 1)) --> 14
tonumb
Definition:
bit.tonumb(bit_tbl) (HTTPLIB)
Description:
convert a bit table into a number
Example:
blshift
Definition:
bit.lshift(a,b) (HTTPLIB)
Description:
returns a shifted left b places
Example:
print (bit.blshift (4, 6)) --> 256
tobits
Definition:
bit.tobits(n) (HTTPLIB)
Description:
convert n into a bit table(which is a 1/0 sequence), high bits first
Example:
blogic_rshift
Definition:
bit.blogic_rshift(n, bits) (HTTPLIB)
Description:
logic right shift(zero fill >>>)
Example:
print (bit.blogic_rshift (144, 1)) --> 72