blob: 8935b4ffc44e627e96bde0c57b6d5d67513cba08 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 string set_bit(string str, int n)
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Return the new string where bit n is set in string str. Note
6 that the old string str is not modified.
MG Mud User88f12472016-06-24 23:31:02 +02007
Zesstra715ec202025-07-09 22:18:31 +02008 Each character contains 6 bits. So you can store a value
9 between 0 and 63 in one character (2^6=64). Starting character
10 is the blank " " which has the value 0. The first charcter in
11 the string is the one with the lowest bits (0-5).
MG Mud User88f12472016-06-24 23:31:02 +020012
Zesstra715ec202025-07-09 22:18:31 +020013 The new string will automatically be extended if needed.
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020016 string s;
17 s=set_bit("?",5);
18
Zesstra715ec202025-07-09 22:18:31 +020019 Because "?" has a value of 31 the variable s will now contain
20 the character "_" which is equal to 63 (31+2^5=63).
MG Mud User88f12472016-06-24 23:31:02 +020021
22 string s;
23 s=set_bit("78",3);
24 s=set_bit(s,8);
25
Zesstra715ec202025-07-09 22:18:31 +020026 s will now contain the string "?<".
MG Mud User88f12472016-06-24 23:31:02 +020027
Zesstra715ec202025-07-09 22:18:31 +020028SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020029 clear_bit(E), last_bit(E), next_bit(E), test_bit(E), count_bits(E),
30 and_bits(E), or_bits(E), xor_bits(E), invert_bits(E), copy_bits(E)