blob: c6e134efc6bf7ac5bd70b5350e30453fd2a48199 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 int test_bit(string str, int n)
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Return 0 or 1 of bit n was set in string str.
MG Mud User88f12472016-06-24 23:31:02 +02006
Zesstra715ec202025-07-09 22:18:31 +02007 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 User88f12472016-06-24 23:31:02 +020011
Zesstra715ec202025-07-09 22:18:31 +020012EXAMPLES
13 test_bit("_",5);
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015 Returns 1 because "_" stands for the number 63 and therefore
16 the 6th bit is set.
MG Mud User88f12472016-06-24 23:31:02 +020017
Zesstra715ec202025-07-09 22:18:31 +020018 test_bit(" ",3);
19
20 Returns 0 because " " stands for 0 and no bit is set.
21
22SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020023 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)