I have the following code
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
int main(){
int x;
cin>>x;
uint32_t Ex;
Ex=(x<<1)>>24;
cout<<Ex<<endl;
return 0;
}
but it gives 0 for any value of x?
My task is the following:
Computation of the biased exponent Ex of a binary32 datum x.
It is not so much that you get zero for ‘any value of x’ but that you get zero for any positive value of x smaller than 0x01000000 (which is 16777216).
None of this helps much with explaining a ‘biassed exponent of a binary32 datum’. That sounds like the exponent of a 32-bit floating point (IEEE) number. You probably have to worry about endianness of the representation, amongst other things.