Core Function BitNOT
From Sputnik Wiki
(Difference between revisions)
UberFoX (Talk | contribs)
(Created page with "<pre> BitNOT( <expression> ) </pre> === Description === Performs a bitwise NOT operation. === Parameters === ==== expression ==== The first number. ==== expression2 ==== T...")
Newer edit →
(Created page with "<pre> BitNOT( <expression> ) </pre> === Description === Performs a bitwise NOT operation. === Parameters === ==== expression ==== The first number. ==== expression2 ==== T...")
Newer edit →
Revision as of 00:07, 28 November 2011
BitNOT( <expression> )
Contents |
Description
Performs a bitwise NOT operation.
Parameters
expression
The first number.
expression2
The second number.
n
Optional; The nth number - up to 255 values can be specified.
Return Value
Returns the bitwise NOT of the value.
Bit operations are performed as 32-bit integers.
Remarks
Remember hex notation can be used for numbers.
Remember that in 2's-complement notation, BitNOT is functionally equivalent to adding 1 and negating the result.
Also remember that NOT changes a 0 bit to 1 and vice-versa.
Some might wonder the point of such a function when clear ~ operators exist but why not!.
Example
$x = BitNot(5); println($x); /* Result is -6 because for 32-bit numbers 5 == 00000000000000000000000000000101 binary -6 == 11111111111111111111111111111010 binary and the first bit is signed */ // Another method $x = ~5; println($x);