Thread: bitset problem

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    bitset problem

    HI all
    I need to build up a bitset object - 90-bits wide - but i can't seem to initialise it. The constructor is probably limited to a 64-bit number? Can i override this (if it is the case)?

    Code:
    bitset<90> hexValLs90(0xFFFFFFFFFFFFFFFFF);
    Code:
    g++ -Wall -g -o netdriver netdriver.cpp
    netdriver.cpp:331:25: warning: integer constant is too large for its type
    netdriver.cpp: In function `int writeSimPatternHeader(std::ofstream&, long int*)':
    netdriver.cpp:331: error: integer constant is too large for "long" type
    I see from this page, that it should work perfectly well? Any ideas?

    Cheers

    S

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The constructor takes an unsigned long (could be 64, could be 32 bits - or other).

    In any case, treating a bitset of this size as a number is going to be a problem.

    What you can do is initialize the bitset to 0 and then flip all bits:

    Code:
    bitset<90> bs;
    bs.flip();
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM