why does my bitset store a max 64 bit value instead of a max 32 bit value when i pass in the max 32 bit value?


0xffffffff is only 32 bit, so can someone tell me why would b be 64 1s? Shouldn't it be printing out 32 0s follow by 32 1s?

#include <iostream>
#include <bitset>

using namespace std;

int main()
   int a = 0xffffffff;

   string b = bitset<64>(a).to_string();
   cout << b;

    return 0;
asked on Stack Overflow Jul 23, 2020 by Astoach167

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0