This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Bug in bitset
On Mon, Nov 19, 2001 at 03:41:43PM +0100, Tomasz Czajka wrote:
> If you try to shift a bitset by a multiple of 32 bits, you get
> incorrect answers. It is to do with the fact that usually 1>>32 == 1.
This program produces the right answer.
$ cat shift.cc
#include <iostream>
#include <bitset>
int main()
{
std::bitset<64> bs;
bs.set(35);
bs >>= 32;
for (int i = 63; i >= 0; --i)
std::cout << bs[i];
std::cout << std::endl;
return 0;
}
$ ./a.out
0000000000000000000000000000000000000000000000000000000000001000
Do you have a test case to demonstrate it? What version of
the library are you running?
Nathan Myers
ncm at cantrip dot org