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]]
 
''new to [[Analytica 4.7]]''
 
  
 
== 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
* '-0' : Trailing (least significant) zero bits.
+
:<code>'-0'</code> : Trailing (least significant) zero bits.
* '-1' : Trailing 1s
+
:<code>'-1'</code> : Trailing 1s
* '0-' : Leading (most significant) 0s.
+
:<code>'0-'</code> : Leading (most significant) 0s.
* '1-' : Leading 1s
+
:<code>'1-'</code> : Leading 1s
  
= Examples =
+
== Examples ==
 +
:<code>BitCount(0) &rarr; 0</code>
 +
:<code>BitCount(13) &rarr; 3  { note: 13 = 0b1101 }</code>
  
:<code>[[BitCount]](0) &rarr; 0</code>
+
Negative numbers are in 64-bit two's complement form, so that
:<code>[[BitCount]](13) &rarr; 3</code>   { note: 13 = 0b1101 }
+
:<code>BitCount(-1) &rarr; 64</code>
  
Negative numbers are in 64-bit two's complement form, so that
+
:<code>BitCount(0b1101010000, which: '-0') &rarr; 4</code>
:<code>[[BitCount]](-1) &rarr; 64</code>
+
:<code>BitCount(0b1101010000, which: '0-') &rarr; 54</code>
 +
:<code>BitCount(0b1101010000, which: '-1') &rarr; 0</code>
 +
:<code>BitCount(0b1101011111, which: '-0') &rarr; 5</code>
 +
:<code>BitCount(-256, which: '1-') &rarr; 56</code>
  
:<code>[[BitCount]]( 0b1101010000, which:'-0')</code> &rarr; 4
+
==History==
:<code>[[BitCount]]( 0b1101010000, which:'0-')</code> &rarr; 54
+
Introduced in [[Analytica 4.7]].
:<code>[[BitCount]]( 0b1101010000, which:'-1')</code> &rarr; 0
 
:<code>[[BitCount]]( 0b1101011111, which:'-0')</code> &rarr; 5
 
:<code>[[BitCount]]( -256, which:'1-')</code> &rarr; 56
 
  
 
== 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


You are not allowed to post comments.