MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | SYNOPSIS |
| 2 | int count_bits (string str) |
| 3 | |
| 4 | DESTRIPTION |
| 5 | Count the number of set bits in bitstring <str> and return the number |
| 6 | as result. |
| 7 | |
| 8 | NOTE |
| 9 | Bitstrings store 6 Bits per Character. Consequently, the functions for |
| 10 | manipulating bitstrings (see below) do generally not work on most |
| 11 | strings. An exception is this (s)efun. It accepts strings which are |
| 12 | not correct bitstrings (like getuid(PL)), BUT: It does NOT work |
| 13 | correctly on them! The results are NOT the correct number of bits! |
| 14 | Additionally, count_bits() in LDMud rejects such strings with an error |
| 15 | instead of returning false results, as all the other functions for |
| 16 | bitstrings do as well. |
| 17 | |
| 18 | EXAMPLES |
| 19 | string s; |
| 20 | |
| 21 | s = set_bit("", 3); s = set_bit(s, 15); |
| 22 | |
| 23 | count_bits(s) --> returns 2 |
| 24 | |
| 25 | SEE ALSO |
| 26 | clear_bit(E), set_bit(E), test_bit(E), next_bit(E), last_bit(E), |
| 27 | or_bits(E), xor_bits(E), invert_bits(E), copy_bits(E) |
| 28 | |
| 29 | 19.12.2006, Zesstra |