Reputation: 35
bitset is not setting the right value when I print it
#include <bitset>
#include <iostream>
using namespace std;
int main()
{
bitset<16> b = 01010;
std::cout << b;
}
1010 in binary is 1111110010 yet it is printing 0000001000001000
Upvotes: 2
Views: 69
Reputation: 9863
Your issue is that you place a 0 in front of your number and so it is being read as if it was octal value. Remove the 0 and everything should work.
Upvotes: 4