Difference between revisions of "BitNot"
(Created page with "category:Bit functions ''new in Analytica 4.7'' == BitNot( x ) == Returns the bitwise one's complement of the integer portion of a number. Each 1 bit in «x» is ch...") |
m (4.7 -> 5.0) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
[[category:Bit functions]] | [[category:Bit functions]] | ||
− | + | == BitNot(x) == | |
− | |||
− | == BitNot( x ) == | ||
− | |||
Returns the bitwise one's complement of the integer portion of a number. Each 1 bit in «x» is changed to 0, and each 0 bit changed to «1». | Returns the bitwise one's complement of the integer portion of a number. Each 1 bit in «x» is changed to 0, and each 0 bit changed to «1». | ||
Each integer is treated as having 64 bits. The two's complement binary representation is used for negative numbers. | Each integer is treated as having 64 bits. The two's complement binary representation is used for negative numbers. | ||
− | This will generally be equivalent to <code>-(x+1)</code> when «x» is an integer, but if you are manipulating the bits of an integer, the use of this function makes your intent more obvious. | + | This will generally be equivalent to <code>-(x + 1)</code> when «x» is an integer, but if you are manipulating the bits of an integer, the use of this function makes your intent more obvious. |
== Examples == | == Examples == | ||
+ | :<code>BitNot(55) → -56</code> | ||
− | |||
The same example shown in [[Binary and hexadecimal integer formats|binary notation]] makes the bit inversion obvious | The same example shown in [[Binary and hexadecimal integer formats|binary notation]] makes the bit inversion obvious | ||
− | :<code> | + | :<code>BitNot(0b110111) → 0b1111111111111111111111111111111111111111111111111111111111001000</code> |
+ | |||
+ | ==History== | ||
+ | Introduced in [[Analytica 5.0]]. | ||
== See Also == | == See Also == | ||
− | * [[BitOr]] | + | * [[BitOr]] |
− | * [[BitCount]] | + | * [[BitAnd]] |
+ | * [[BitXOr]] | ||
+ | * [[BitCount]] | ||
+ | * [[BitShift]] | ||
* Logical [[Not]] | * Logical [[Not]] |
Latest revision as of 01:27, 28 April 2016
BitNot(x)
Returns the bitwise one's complement of the integer portion of a number. Each 1 bit in «x» is changed to 0, and each 0 bit changed to «1».
Each integer is treated as having 64 bits. The two's complement binary representation is used for negative numbers.
This will generally be equivalent to -(x + 1)
when «x» is an integer, but if you are manipulating the bits of an integer, the use of this function makes your intent more obvious.
Examples
BitNot(55) → -56
The same example shown in binary notation makes the bit inversion obvious
BitNot(0b110111) → 0b1111111111111111111111111111111111111111111111111111111111001000
History
Introduced in Analytica 5.0.
See Also
Comments
Enable comment auto-refresher