Bitset is a container that can store binary data.
Major bitset operations include:
-
(Constructor)
-
Construct bitset (Public member function) // construct the bitset... format: bitset <length> name
-
Applicable Operators
-
Bitset operators (functions) // you can directly perform binary operations on the bitset container, such as ^, | ,~, <,> And so on
-
OPERATOR []
-
Access bit (Public member function) // values can be assigned as arrays. Bitset <4> B; B [0] = 1;
-
Set
-
Set bits (Public member function) // by default, all values in the container are assigned as 1, and specific positions can be assigned to specific values.
-
Such as bitset <4> B; B. Set (); // 1111. B. Set (1011.
-
Reset
-
Reset bits (Public member function) // by default, all values in the container are assigned 0 values. You can also assign specific values to specific locations.
-
Flip
-
Flip bits (Public member function) // by default, the number in the container is reversed, 1 is changed to 0, 0 is changed to 1, you can also reverse bitset <4> B (string ("0001"); B. file (2); // 0101; B. file ();
// 1010
-
To_ulong
-
Convert to unsigned long integer (Public member function) // convert the container value to a decimal number.
-
To_string
-
Convert to string (Public member function) // convert the container's tired value into a string
-
Count
-
Count Bits Set (Public member function) // count the number of 1 in the container
-
Size
-
Return size (Public member function) // container size
-
Test
-
Return bit value (Public member function) // returns the number at each position.
-
Any
-
Test if any bit is set (Public member function) // if the container value is greater than 0, the system returns true.
-
None
-
Test if no bit is set (Public member function) // and any get the inverse. The container value = 0 returns true. Otherwise