blob: 3936170a0fa591e7365dca0a96e3d1c40c1c92b9 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 int last_bit(string str)
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Return the number of the last set bit in bitstring <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
MG Mud User88f12472016-06-24 23:31:02 +020013 string s;
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015 s = set_bit("", 4); s = set_bit(s, 2);
16
17 last_bit(s) --> returns 4
18
19SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020020 set_bit(E), clear_bit(E), next_bit(E), test_bit(E), count_bits(E),
21 and_bits(E), or_bits(E), xor_bits(E), invert_bits(E), copy_bits(E)