Commit 9f022e98 authored by Marcel Stör's avatar Marcel Stör
Browse files

Manually applying changes from #2093

parent 082015eb
...@@ -9,166 +9,166 @@ Bit manipulation support, on 32bit integers. ...@@ -9,166 +9,166 @@ Bit manipulation support, on 32bit integers.
## bit.arshift() ## bit.arshift()
Arithmetic right shift a number equivalent to `value >> shift` in C. Arithmetic right shift a number equivalent to `value >> shift` in C.
####Syntax #### Syntax
`bit.arshift(value, shift)` `bit.arshift(value, shift)`
####Parameters #### Parameters
- `value` the value to shift - `value` the value to shift
- `shift` positions to shift - `shift` positions to shift
####Returns #### Returns
the number shifted right (arithmetically) the number shifted right (arithmetically)
## bit.band() ## bit.band()
Bitwise AND, equivalent to `val1 & val2 & ... & valn` in C. Bitwise AND, equivalent to `val1 & val2 & ... & valn` in C.
####Syntax #### Syntax
`bit.band(val1, val2 [, ... valn])` `bit.band(val1, val2 [, ... valn])`
####Parameters #### Parameters
- `val1` first AND argument - `val1` first AND argument
- `val2` second AND argument - `val2` second AND argument
- `...valn` ...nth AND argument - `...valn` ...nth AND argument
####Returns #### Returns
the bitwise AND of all the arguments (number) the bitwise AND of all the arguments (number)
## bit.bit() ## bit.bit()
Generate a number with a 1 bit (used for mask generation). Equivalent to `1 << position` in C. Generate a number with a 1 bit (used for mask generation). Equivalent to `1 << position` in C.
####Syntax #### Syntax
`bit.bit(position)` `bit.bit(position)`
####Parameters #### Parameters
`position` position of the bit that will be set to 1 `position` position of the bit that will be set to 1
####Returns #### Returns
a number with only one 1 bit at position (the rest are set to 0) a number with only one 1 bit at position (the rest are set to 0)
## bit.bnot() ## bit.bnot()
Bitwise negation, equivalent to `~value in C. Bitwise negation, equivalent to `~value in C.`
####Syntax #### Syntax
`bit.bnot(value)` `bit.bnot(value)`
####Parameters #### Parameters
`value` the number to negate `value` the number to negate
####Returns #### Returns
the bitwise negated value of the number the bitwise negated value of the number
## bit.bor() ## bit.bor()
Bitwise OR, equivalent to `val1 | val2 | ... | valn` in C. Bitwise OR, equivalent to `val1 | val2 | ... | valn` in C.
####Syntax #### Syntax
`bit.bor(val1, val2 [, ... valn])` `bit.bor(val1, val2 [, ... valn])`
####Parameters #### Parameters
- `val1` first OR argument. - `val1` first OR argument.
- `val2` second OR argument. - `val2` second OR argument.
- `...valn` ...nth OR argument - `...valn` ...nth OR argument
####Returns #### Returns
the bitwise OR of all the arguments (number) the bitwise OR of all the arguments (number)
## bit.bxor() ## bit.bxor()
Bitwise XOR, equivalent to `val1 ^ val2 ^ ... ^ valn` in C. Bitwise XOR, equivalent to `val1 ^ val2 ^ ... ^ valn` in C.
####Syntax #### Syntax
`bit.bxor(val1, val2 [, ... valn])` `bit.bxor(val1, val2 [, ... valn])`
####Parameters #### Parameters
- `val1` first XOR argument - `val1` first XOR argument
- `val2` second XOR argument - `val2` second XOR argument
- `...valn` ...nth XOR argument - `...valn` ...nth XOR argument
####Returns #### Returns
the bitwise XOR of all the arguments (number) the bitwise XOR of all the arguments (number)
## bit.clear() ## bit.clear()
Clear bits in a number. Clear bits in a number.
####Syntax #### Syntax
`bit.clear(value, pos1 [, ... posn])` `bit.clear(value, pos1 [, ... posn])`
####Parameters #### Parameters
- `value` the base number - `value` the base number
- `pos1` position of the first bit to clear - `pos1` position of the first bit to clear
- `...posn` position of thet nth bit to clear - `...posn` position of thet nth bit to clear
####Returns #### Returns
the number with the bit(s) cleared in the given position(s) the number with the bit(s) cleared in the given position(s)
## bit.isclear() ## bit.isclear()
Test if a given bit is cleared. Test if a given bit is cleared.
####Syntax #### Syntax
`bit.isclear(value, position)` `bit.isclear(value, position)`
####Parameters #### Parameters
- `value` the value to test - `value` the value to test
- `position` bit position to test - `position` bit position to test
####Returns #### Returns
true if the bit at the given position is 0, false othewise true if the bit at the given position is 0, false othewise
## bit.isset() ## bit.isset()
Test if a given bit is set. Test if a given bit is set.
####Syntax #### Syntax
`bit.isset(value, position)` `bit.isset(value, position)`
####Parameters #### Parameters
- `value` the value to test - `value` the value to test
- `position` bit position to test - `position` bit position to test
####Returns #### Returns
true if the bit at the given position is 1, false otherwise true if the bit at the given position is 1, false otherwise
## bit.lshift() ## bit.lshift()
Left-shift a number, equivalent to `value << shift` in C. Left-shift a number, equivalent to `value << shift` in C.
####Syntax #### Syntax
`bit.lshift(value, shift)` `bit.lshift(value, shift)`
####Parameters #### Parameters
- `value` the value to shift - `value` the value to shift
- `shift` positions to shift - `shift` positions to shift
####Returns #### Returns
the number shifted left the number shifted left
## bit.rshift() ## bit.rshift()
Logical right shift a number, equivalent to `( unsigned )value >> shift` in C. Logical right shift a number, equivalent to `( unsigned )value >> shift` in C.
####Syntax #### Syntax
`bit.rshift(value, shift)` `bit.rshift(value, shift)`
####Parameters #### Parameters
- `value` the value to shift. - `value` the value to shift.
- `shift` positions to shift. - `shift` positions to shift.
####Returns #### Returns
the number shifted right (logically) the number shifted right (logically)
## bit.set() ## bit.set()
Set bits in a number. Set bits in a number.
####Syntax #### Syntax
`bit.set(value, pos1 [, ... posn ])` `bit.set(value, pos1 [, ... posn ])`
####Parameters #### Parameters
- `value` the base number. - `value` the base number.
- `pos1` position of the first bit to set. - `pos1` position of the first bit to set.
- `...posn` position of the nth bit to set. - `...posn` position of the nth bit to set.
####Returns #### Returns
the number with the bit(s) set in the given position(s) the number with the bit(s) set in the given position(s)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment