BitCountString (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:
==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>

Revision as of 01:26, 22 March 2013

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