BitCountString (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Template:String:BitCountString subtitle}}
{{Template:String:BitCountString subtitle}}
This function counts the number of on bits in a string.
This function counts the number of on bits in a string.
==Syntax==
==Syntax==
Line 16: Line 15:
==Examples==
==Examples==
The following example counts the number of on bits in the EBCDIC representation of the string "City of Brotherly Love" and assigns it to a variable:
The following example counts the number of on bits in the EBCDIC representation of the string "City of Brotherly Love" and assigns it to a variable:
<p class="code">
<p class="code">%homMuchLove = "City of Brotherly Love":bitCountString
%homMuchLove = "City of Brotherly Love":bitCountString
</p>
</p>
==See also==
==See also==
<table>
<table>

Latest revision as of 20:13, 3 September 2015

Count number of on bits in a string (String class)

[Introduced in Model 204 7.5]

This function counts the number of on bits in a string.

Syntax

%count = string:BitCountString

Syntax terms

%countSet to the number of bits that were on in the method object string.
string The string in which on bits are to be counted.

Usage notes

  • Since there are 8 bits in every byte of a string, the result of the BitCountString function will always be a number from 0 to the length of the method object string times 8.

Examples

The following example counts the number of on bits in the EBCDIC representation of the string "City of Brotherly Love" and assigns it to a variable:

%homMuchLove = "City of Brotherly Love":bitCountString

See also