0

Edit

The error occurs only for 32 bites right shift.


Okay so I'm trying to shift 4 278 255 360 -> 1111 1111 0000 0000 1111 1111 0000 000 in binary for 32 into the right.

Yet the return of the simple function is -> 1111 1111 0000 0000 1111 1111 0000 0000 as if nothing happened.

Using bitset just so I see if the shifting if it's correct.

Code I'm using.

#include <iostream>
#include <bitset>

using namespace std;

int rshift(unsigned int a,unsigned int b){
    return a >> b;  
}

main(){
    unsigned int a=0, b=0;
    cin >> a;
    cin >> b;
    bitset<32> one (a);
    bitset<32> two (b);
    int end = rshift(a, b); 
    bitset<32> three (end);
    cout << one << endl;
    cout << two << endl;
    cout << three << endl;

    return 0;
}

0 Answers0