Difference between revisions of "Bit"
(→Functions) |
(→Functions) |
||
Line 7: | Line 7: | ||
'''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> | ||
Line 22: | Line 18: | ||
'''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> | ||
Line 37: | 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> | ||
Line 52: | 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> | ||
Line 67: | 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> | ||
Line 80: | Line 60: | ||
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 95: | Line 71: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
convert a bit table into a number | convert a bit table into a number | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 109: | Line 81: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
returns a shifted left b places | returns a shifted left b places | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 124: | Line 92: | ||
'''Description:''' <br> | '''Description:''' <br> | ||
convert n into a bit table(which is a 1/0 sequence), high bits first | convert n into a bit table(which is a 1/0 sequence), high bits first | ||
− | |||
− | |||
− | |||
− | |||
<br><br> | <br><br> | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 138: | Line 102: | ||
'''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 | print (bit.blogic_rshift (144, 1)) --> 72 | ||
<br><br> | <br><br> |
Revision as of 14:11, 31 May 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:
Description:
Example:
print (bit.xor (15, 1)) --> 14
tonumb
Definition:
bit.tonumb(bit_tbl)
Description:
convert a bit table into a number
Example:
blshift
Definition:
bit.lshift(a,b)
Description:
returns a shifted left b places
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
Example:
blogic_rshift
Definition:
bit.blogic_rshift(n, bits)
Description:
logic right shift(zero fill >>>)
Example:
print (bit.blogic_rshift (144, 1)) --> 72