Thread: Bitset help

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    34

    Bitset help

    Code:
    #include <iostream> #include <bitset>  using namespace std;  int main() {   bitset<8> bits = 83;    cout << bits << "  ";   cout << bits.to_ulong() << endl << endl;    bits[0] = 0;    cout << bits << "  ";   cout << bits.to_ulong() << endl << endl;    bits[1] = 0;    cout << bits << "  ";   cout << bits.to_ulong() << endl << endl;    return 0; }


    id like if bitset could be explained to me so I could determine the output of this program.
    I understand that it converts the number into an integer?
    an example using the format about would be great.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Dunno if this is the same as your other bitset question, but until you reformat your post so you don't have code on one line, nobody will care.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bitset problem
    By Ingersoll in forum C++ Programming
    Replies: 1
    Last Post: 09-29-2009, 04:32 AM
  2. bitset + memcpy
    By KBriggs in forum C++ Programming
    Replies: 7
    Last Post: 08-14-2009, 01:04 PM
  3. Bitset questions
    By serge in forum C++ Programming
    Replies: 17
    Last Post: 05-07-2008, 02:00 PM
  4. possible to have pointers in bitset?
    By franziss in forum C++ Programming
    Replies: 23
    Last Post: 04-07-2007, 10:19 PM
  5. errors with bitset
    By Marksman in forum C++ Programming
    Replies: 11
    Last Post: 07-12-2006, 12:15 PM

Tags for this Thread