Difference between revisions of "BitCount"
(Created page with "category:Bit functions ''new to Analytica 4.7'' == BitCount(x'', which'') == Counts the number of 1 bits in the 64-bit integer portion of «x». The optional «whi...") |
|||
Line 1: | Line 1: | ||
[[category:Bit functions]] | [[category:Bit functions]] | ||
− | |||
− | |||
== BitCount(x'', which'') == | == BitCount(x'', which'') == | ||
Line 8: | Line 6: | ||
The optional «which» parameter can be one of the following text values | The optional «which» parameter can be one of the following text values | ||
− | + | :<code>'-0'</code> : Trailing (least significant) zero bits. | |
− | + | :<code>'-1'</code> : Trailing 1s | |
− | + | :<code>'0-'</code> : Leading (most significant) 0s. | |
− | + | :<code>'1-'</code> : Leading 1s | |
− | = Examples = | + | == Examples == |
+ | :<code>BitCount(0) → 0</code> | ||
+ | :<code>BitCount(13) → 3 { note: 13 = 0b1101 }</code> | ||
− | + | Negative numbers are in 64-bit two's complement form, so that | |
− | :<code> | + | :<code>BitCount(-1) → 64</code> |
− | + | :<code>BitCount(0b1101010000, which: '-0') → 4</code> | |
− | :<code> | + | :<code>BitCount(0b1101010000, which: '0-') → 54</code> |
+ | :<code>BitCount(0b1101010000, which: '-1') → 0</code> | ||
+ | :<code>BitCount(0b1101011111, which: '-0') → 5</code> | ||
+ | :<code>BitCount(-256, which: '1-') → 56</code> | ||
− | + | ==History== | |
− | + | Introduced in [[Analytica 4.7]]. | |
− | |||
− | |||
− | |||
== See Also == | == See Also == | ||
− | |||
* [[BitAnd]] | * [[BitAnd]] | ||
* [[BitOr]] | * [[BitOr]] |
Revision as of 04:44, 26 January 2016
BitCount(x, which)
Counts the number of 1 bits in the 64-bit integer portion of «x».
The optional «which» parameter can be one of the following text values
'-0'
: Trailing (least significant) zero bits.'-1'
: Trailing 1s'0-'
: Leading (most significant) 0s.'1-'
: Leading 1s
Examples
BitCount(0) → 0
BitCount(13) → 3 { note: 13 = 0b1101 }
Negative numbers are in 64-bit two's complement form, so that
BitCount(-1) → 64
BitCount(0b1101010000, which: '-0') → 4
BitCount(0b1101010000, which: '0-') → 54
BitCount(0b1101010000, which: '-1') → 0
BitCount(0b1101011111, which: '-0') → 5
BitCount(-256, which: '1-') → 56
History
Introduced in Analytica 4.7.
See Also
Comments
Enable comment auto-refresher