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