Below code works first two times thru and then on the third time the convert to ulong fails and gives me a 0XCF instead of 0xF3. Any idea what the problem is?? Seems like a bug in the VS 2010 to_long. binary '11110011' should convert to Hex F3! Here are the results when running debug under VS 2010.
1ST TIME bc_bit_char b'11000011' converts to k = x'000000c3'; 2ND TIME: bc_bit_char b'00111100' converts to k = x'0000003c' 3RD TIME: bc_bit_char b'11110011' converts to k = x'000000cf' WRONG! s/b x'000000f3'
std::bitset<8> bc_bit_char (00000000);
unsigned char bc_char=' ', bc_convert_char=' ';
unsigned long k=0, bc_rows=0;
k = bc_bit_char.to_ulong(); // convert 8 bits to long integer with same bits
bc_convert_char = static_cast<unsigned char> (k); // convert long integer to unsigned