MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | int test_bit(string str, int n) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 4 | DESCRIPTION |
| 5 | Return 0 or 1 of bit n was set in string str. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 6 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 7 | Each character contains 6 bits. So you can store a value |
| 8 | between 0 and 63 in one character (2^6=64). Starting character |
| 9 | is the blank " " which has the value 0. The first character in |
| 10 | the string is the one with the lowest bits (0-5). |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 12 | EXAMPLES |
| 13 | test_bit("_",5); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 14 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 15 | Returns 1 because "_" stands for the number 63 and therefore |
| 16 | the 6th bit is set. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 17 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 18 | test_bit(" ",3); |
| 19 | |
| 20 | Returns 0 because " " stands for 0 and no bit is set. |
| 21 | |
| 22 | SEE ALSO |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 23 | set_bit(E), clear_bit(E), last_bit(E), next_bit(E), count_bits(E), |
| 24 | and_bits(E), or_bits(E), xor_bits(E), invert_bits(E), copy_bits(E) |